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
24#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
25 template<>
26 struct is_supported_char<char16_t> : std::true_type {};
27#endif
28
29#ifdef BOOST_LOCALE_ENABLE_CHAR32_T
30 template<>
31 struct is_supported_char<char32_t> : std::true_type {};
32#endif
33
34 template<typename Char>
35 using enable_if_is_supported_char = typename std::enable_if<is_supported_char<Char>::value>::type;
36
37}}} // namespace boost::locale::detail
38
39#define BOOST_LOCALE_ASSERT_IS_SUPPORTED(Char) \
40 static_assert(boost::locale::detail::is_supported_char<Char>::value, "Unsupported Char type")
41
43
44#endif