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 5 #ifndef BOOST_CONVERT_DETAIL_IS_CHAR_HPP 6 #define BOOST_CONVERT_DETAIL_IS_CHAR_HPP 7 8 #include <boost/convert/detail/config.hpp> 9 #include <cctype> 10 #include <cwctype> 11 12 namespace boost { namespace cnv 13 { 14 using char_type = char; 15 using uchar_type = unsigned char; 16 using wchar_type = wchar_t; 17 18 namespace detail 19 { 20 template<typename> struct is_char : std::false_type {}; 21 template<> struct is_char< char_type> : std:: true_type {}; 22 template<> struct is_char<wchar_type> : std:: true_type {}; 23 } 24 template <typename T> struct is_char : detail::is_char<typename boost::remove_const<T>::type> {}; 25 26 template<typename char_type> inline bool is_space(char_type); 27 template<typename char_type> inline char_type to_upper(char_type); 28 is_space(char_type c)29 template<> inline bool is_space ( char_type c) { return bool(std::isspace(static_cast<uchar_type>(c))); } is_space(uchar_type c)30 template<> inline bool is_space (uchar_type c) { return bool(std::isspace(c)); } is_space(wchar_type c)31 template<> inline bool is_space (wchar_type c) { return bool(std::iswspace(c)); } to_upper(char_type c)32 template<> inline char_type to_upper ( char_type c) { return std::toupper(static_cast<uchar_type>(c)); } to_upper(uchar_type c)33 template<> inline uchar_type to_upper (uchar_type c) { return std::toupper(c); } to_upper(wchar_type c)34 template<> inline wchar_type to_upper (wchar_type c) { return std::towupper(c); } 35 }} 36 37 #endif // BOOST_CONVERT_DETAIL_IS_CHAR_HPP 38 39