is_string.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2009-2020 Vladimir Batov.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
  4. #ifndef BOOST_CONVERT_DETAIL_IS_STRING_HPP
  5. #define BOOST_CONVERT_DETAIL_IS_STRING_HPP
  6. #include <boost/convert/detail/range.hpp>
  7. namespace boost { namespace cnv
  8. {
  9. namespace detail
  10. {
  11. template<typename T, bool is_range_class> struct is_string : std::false_type {};
  12. template<typename T> struct is_string<T*, false>
  13. {
  14. static bool BOOST_CONSTEXPR_OR_CONST value = cnv::is_char<T>::value;
  15. };
  16. template <typename T, std::size_t N> struct is_string<T [N], false>
  17. {
  18. static bool BOOST_CONSTEXPR_OR_CONST value = cnv::is_char<T>::value;
  19. };
  20. template<typename T> struct is_string<T, /*is_range_class=*/true>
  21. {
  22. static bool BOOST_CONSTEXPR_OR_CONST value = cnv::is_char<typename T::value_type>::value;
  23. };
  24. }
  25. template<typename T>
  26. struct is_string : detail::is_string<
  27. typename std::remove_const<T>::type,
  28. std::is_class<T>::value && cnv::is_range<T>::value>
  29. {};
  30. }}
  31. #endif // BOOST_CONVERT_DETAIL_IS_STRING_HPP