8 #ifndef BOOST_NOWIDE_DETAIL_IS_STRING_CONTAINER_HPP_INCLUDED 9 #define BOOST_NOWIDE_DETAIL_IS_STRING_CONTAINER_HPP_INCLUDED 12 #include <type_traits> 24 using void_t =
typename make_void<Ts...>::type;
27 struct is_char_type : std::false_type
30 struct is_char_type<char> : std::true_type
33 struct is_char_type<wchar_t> : std::true_type
36 struct is_char_type<char16_t> : std::true_type
39 struct is_char_type<char32_t> : std::true_type
43 struct is_char_type<char8_t> : std::true_type
48 struct is_c_string : std::false_type
51 struct is_c_string<const T*> : is_char_type<T>
55 using const_data_result = decltype(std::declval<const T>().data());
58 using get_data_width =
59 std::integral_constant<std::size_t,
sizeof(
typename std::remove_pointer<const_data_result<T>>::type)>;
61 using size_result = decltype(std::declval<T>().size());
64 using has_narrow_data = std::integral_constant<bool, (get_data_width<T>::value == 1)>;
69 template<
typename T,
bool isNarrow,
typename =
void>
70 struct is_string_container : std::false_type
73 template<
typename T,
bool isNarrow>
74 struct is_string_container<T, isNarrow, void_t<decltype(T::npos), size_result<T>, const_data_result<T>>>
75 : std::integral_constant<bool,
76 std::is_integral<decltype(T::npos)>::value
77 && std::is_integral<size_result<T>>::value
78 && is_c_string<const_data_result<T>>::value
79 && isNarrow == has_narrow_data<T>::value>
83 using requires_narrow_string_container =
typename std::enable_if<is_string_container<T, true>::value>::type;
85 using requires_wide_string_container =
typename std::enable_if<is_string_container<T, false>::value>::type;
88 using requires_narrow_char =
typename std::enable_if<
sizeof(T) == 1 && is_char_type<T>::value>::type;
90 using requires_wide_char =
typename std::enable_if<(
sizeof(T) > 1) && is_char_type<T>::value>::type;