is_cstring.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision$
  10. //
  11. // Description : defines the is_cstring type trait
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_UTILS_IS_CSTRING_HPP
  14. #define BOOST_TEST_UTILS_IS_CSTRING_HPP
  15. // Boost
  16. #include <boost/mpl/bool.hpp>
  17. #include <boost/type_traits/is_same.hpp>
  18. #include <boost/type_traits/decay.hpp>
  19. #include <boost/type_traits/remove_pointer.hpp>
  20. //____________________________________________________________________________//
  21. namespace boost {
  22. namespace unit_test {
  23. // ************************************************************************** //
  24. // ************** is_cstring ************** //
  25. // ************************************************************************** //
  26. namespace ut_detail {
  27. template<typename T>
  28. struct is_cstring_impl : public mpl::false_ {};
  29. template<typename T>
  30. struct is_cstring_impl<T const*> : public is_cstring_impl<T*> {};
  31. template<typename T>
  32. struct is_cstring_impl<T const* const> : public is_cstring_impl<T*> {};
  33. template<>
  34. struct is_cstring_impl<char*> : public mpl::true_ {};
  35. template<>
  36. struct is_cstring_impl<wchar_t*> : public mpl::true_ {};
  37. } // namespace ut_detail
  38. template<typename T>
  39. struct is_cstring : public ut_detail::is_cstring_impl<typename decay<T>::type> {};
  40. } // namespace unit_test
  41. } // namespace boost
  42. #endif // BOOST_TEST_UTILS_IS_CSTRING_HPP