Boost.Locale
is_supported_char.hpp
1//
2// Copyright (c) 2022-2023 Alexander Grund
3//
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#ifndef BOOST_LOCALE_DETAIL_IS_SUPPORTED_CHAR_HPP_INCLUDED
8#define BOOST_LOCALE_DETAIL_IS_SUPPORTED_CHAR_HPP_INCLUDED
9
10#include <boost/locale/config.hpp>
11#include <type_traits>
12
14namespace boost { namespace locale { namespace detail {
16 template<typename Char>
17 struct is_supported_char : std::false_type {};
18
19 template<>
20 struct is_supported_char<char> : std::true_type {};
21 template<>
22 struct is_supported_char<wchar_t> : std::true_type {};
23#ifdef __cpp_char8_t
24 template<>
25 struct is_supported_char<char8_t> : std::true_type {};
26#endif
27
28#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
29 template<>
30 struct is_supported_char<char16_t> : std::true_type {};
31#endif
32
33#ifdef BOOST_LOCALE_ENABLE_CHAR32_T
34 template<>
35 struct is_supported_char<char32_t> : std::true_type {};
36#endif
37
38 template<typename Char>
39 using enable_if_is_supported_char = typename std::enable_if<is_supported_char<Char>::value>::type;
40
41}}} // namespace boost::locale::detail
42
43#define BOOST_LOCALE_ASSERT_IS_SUPPORTED(Char) \
44 static_assert(boost::locale::detail::is_supported_char<Char>::value, "Unsupported Char type")
45
47
48#endif