// // Copyright (c) 2020 Alexander Grund // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE or copy at // http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_NOWIDE_DETAIL_IS_STRING_CONTAINER_HPP_INCLUDED #define BOOST_NOWIDE_DETAIL_IS_STRING_CONTAINER_HPP_INCLUDED #include #include namespace boost { namespace nowide { namespace detail { template struct make_void { typedef void type; }; template using void_t = typename make_void::type; template struct is_char_type : std::false_type {}; template<> struct is_char_type : std::true_type {}; template<> struct is_char_type : std::true_type {}; template<> struct is_char_type : std::true_type {}; template<> struct is_char_type : std::true_type {}; #ifdef __cpp_char8_t template<> struct is_char_type : std::true_type {}; #endif template struct is_c_string : std::false_type {}; template struct is_c_string : is_char_type {}; template using const_data_result = decltype(std::declval().data()); /// Return the size of the char type returned by the data() member function template using get_data_width = std::integral_constant>::type)>; template using size_result = decltype(std::declval().size()); /// Return true if the data() member function returns a pointer to a type of size 1 template using has_narrow_data = std::integral_constant::value == 1)>; /// Return true if T is a string container, e.g. std::basic_string, std::basic_string_view /// Requires a static value `npos`, a member function `size()` returning an integral, /// and a member function `data()` returning a C string template struct is_string_container : std::false_type {}; // clang-format off template struct is_string_container, const_data_result>> : std::integral_constant::value && std::is_integral>::value && is_c_string>::value && isNarrow == has_narrow_data::value> {}; // clang-format on template using requires_narrow_string_container = typename std::enable_if::value>::type; template using requires_wide_string_container = typename std::enable_if::value>::type; template using requires_narrow_char = typename std::enable_if::value>::type; template using requires_wide_char = typename std::enable_if<(sizeof(T) > 1) && is_char_type::value>::type; } // namespace detail } // namespace nowide } // namespace boost #endif