Enable char8_t strings where available, remove Clang condition

The issue was caused by using an incompatible libstdc++.
For Clang 13 & 14 libstdc++ 11 works.
This commit is contained in:
Alexander Grund 2025-01-02 19:35:44 +01:00
parent c2147f6486
commit e540a63c0b
22 changed files with 32 additions and 37 deletions

View File

@ -100,7 +100,7 @@ namespace boost { namespace locale { namespace boundary {
typedef boundary_point<std::string::const_iterator> sboundary_point; ///< convenience typedef
typedef boundary_point<std::wstring::const_iterator> wsboundary_point; ///< convenience typedef
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
typedef boundary_point<std::u8string::const_iterator> u8sboundary_point; ///< convenience typedef
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T

View File

@ -868,7 +868,7 @@ namespace boost { namespace locale { namespace boundary {
typedef segment_index<std::string::const_iterator> ssegment_index; ///< convenience typedef
typedef segment_index<std::wstring::const_iterator> wssegment_index; ///< convenience typedef
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
typedef segment_index<std::u8string::const_iterator> u8ssegment_index; ///< convenience typedef
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
@ -892,7 +892,7 @@ namespace boost { namespace locale { namespace boundary {
typedef boundary_point_index<std::string::const_iterator> sboundary_point_index; ///< convenience typedef
typedef boundary_point_index<std::wstring::const_iterator> wsboundary_point_index; ///< convenience typedef
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
typedef boundary_point_index<std::u8string::const_iterator> u8sboundary_point_index; ///< convenience typedef
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T

View File

@ -340,7 +340,7 @@ namespace boost { namespace locale { namespace boundary {
typedef segment<std::string::const_iterator> ssegment; ///< convenience typedef
typedef segment<std::wstring::const_iterator> wssegment; ///< convenience typedef
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
typedef segment<std::u8string::const_iterator> u8ssegment; ///< convenience typedef
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T

View File

@ -89,11 +89,6 @@
# define BOOST_LOCALE_NO_SANITIZE(what)
#endif
#if !defined(__cpp_lib_char8_t) || BOOST_WORKAROUND(BOOST_CLANG_VERSION, < 150000)
// No std::basic_string<char8_t> or bug in Clang: https://github.com/llvm/llvm-project/issues/55560
# define BOOST_LOCALE_NO_CXX20_STRING8
#endif
/// \endcond
#endif // boost/locale/config.hpp

View File

@ -418,7 +418,7 @@ namespace boost { namespace locale {
typedef basic_format<char> format;
/// Definition of wchar_t based format
typedef basic_format<wchar_t> wformat;
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
/// Definition of char8_t based format
typedef basic_format<char8_t> u8format;
#endif

View File

@ -341,7 +341,7 @@ namespace boost { namespace locale {
typedef basic_message<char> message;
/// Convenience typedef for wchar_t
typedef basic_message<wchar_t> wmessage;
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
/// Convenience typedef for char8_t
typedef basic_message<char8_t> u8message;
#endif

View File

@ -224,7 +224,7 @@ namespace boost { namespace locale { namespace conv {
BOOST_LOCALE_INSTANTIATE(char);
BOOST_LOCALE_INSTANTIATE_NO_CHAR(wchar_t);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
BOOST_LOCALE_INSTANTIATE_NO_CHAR(char8_t);
#endif

View File

@ -198,7 +198,7 @@ namespace boost { namespace locale { namespace impl_icu {
return std::locale(in, new utf8_converter_impl<char>(cd));
return std::locale(in, new converter_impl<char>(cd));
case char_facet_t::wchar_f: return std::locale(in, new converter_impl<wchar_t>(cd));
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter_impl<char8_t>(cd));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;

View File

@ -125,7 +125,7 @@ namespace boost { namespace locale { namespace impl_posix {
return std::locale(in, new std_converter<char>(std::move(lc)));
}
case char_facet_t::wchar_f: return std::locale(in, new std_converter<wchar_t>(std::move(lc)));
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter<char8_t>(std::move(lc)));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;

View File

@ -620,7 +620,7 @@ namespace boost { namespace locale { namespace detail {
case char_facet_t::nochar: break;
case char_facet_t::char_f: return std::locale(in, gnu_gettext::create_messages_facet<char>(minf));
case char_facet_t::wchar_f: return std::locale(in, gnu_gettext::create_messages_facet<wchar_t>(minf));
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, gnu_gettext::create_messages_facet<char8_t>(minf));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;

View File

@ -104,7 +104,7 @@ namespace boost { namespace locale { namespace impl_std {
else
return std::locale(in, new std_converter<char>(locale_name));
case char_facet_t::wchar_f: return std::locale(in, new std_converter<wchar_t>(locale_name));
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter<char8_t>(locale_name));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;

View File

@ -9,7 +9,7 @@
#include <boost/locale/config.hpp>
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
# define BOOST_LOCALE_FOREACH_CHAR_I_CHAR8_T(F) F(char8_t)
# define BOOST_LOCALE_FOREACH_CHAR_I2_CHAR8_T(F) F(char8_t)
#elif defined(__cpp_char8_t)

View File

@ -62,7 +62,7 @@ namespace boost { namespace locale { namespace impl_win {
case char_facet_t::nochar: break;
case char_facet_t::char_f: return std::locale(in, new utf8_converter<char>(lc));
case char_facet_t::wchar_f: return std::locale(in, new wide_converter(lc));
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter<char8_t>(lc));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;

View File

@ -113,7 +113,7 @@ std::basic_string<Char> to(const std::string& utf8)
return out;
}
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
template<>
std::basic_string<char8_t> to(const std::string& utf8)
{

View File

@ -65,7 +65,7 @@ void test_main(int /*argc*/, char** /*argv*/)
std::cout << "no\n";
#endif
std::cout << "- std::basic_string<char8_t>: ";
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << "yes\n";
#elif defined(__cpp_lib_char8_t)
std::cout << "partial\n";

View File

@ -310,7 +310,7 @@ void test_boundaries(std::string* all, int* first, int* second, lb::boundary_typ
run_word<char>(all, first, second, nullptr, nullptr, nullptr, g("he_IL.cp1255"), t);
std::cout << " wchar_t" << std::endl;
run_word<wchar_t>(all, first, second, nullptr, nullptr, nullptr, g("he_IL.UTF-8"), t);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
run_word<char8_t>(all, first, second, nullptr, nullptr, nullptr, g("he_IL.UTF-8"), t);
#endif
@ -373,7 +373,7 @@ void word_boundary()
run_word<wchar_t>(txt_simple, none_simple, zero, word_simple, zero, zero, utf8_en_locale);
run_word<wchar_t>(txt_all, none_all, num_all, word_all, kana_all, ideo_all, utf8_jp_locale);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
run_word<char8_t>(txt_empty, zero, zero, zero, zero, zero, g("ja_JP.UTF-8"));
run_word<char8_t>(txt_simple, none_simple, zero, word_simple, zero, zero, utf8_en_locale);

View File

@ -25,7 +25,7 @@ void test_norm(std::string orig, std::string normal, boost::locale::norm_type ty
{
test_normc<char>(orig, normal, type);
test_normc<wchar_t>(to<wchar_t>(orig), to<wchar_t>(normal), type);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
test_normc<char8_t>(to<char8_t>(orig), to<char8_t>(normal), type);
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T
@ -105,7 +105,7 @@ void test_main(int /*argc*/, char** /*argv*/)
TEST_ALL_CASES;
#undef TEST_V
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
# define TEST_V(how, source_s, dest_s) TEST_A(char8_t, how, to<char8_t>(source_s), to<char8_t>(dest_s))
TEST_ALL_CASES;
# undef TEST_V

View File

@ -425,7 +425,7 @@ void test_utf_to_utf_for()
test_from_utf_for_impls(utf<Char>(utf8_string), utf8_string, "UTF-8");
std::cout << "---- wchar_t\n";
test_utf_to_utf_for<Char, wchar_t>(utf8_string);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << "---- char8_t\n";
test_utf_to_utf_for<Char, char8_t>(utf8_string);
#endif
@ -446,7 +446,7 @@ void test_utf_to_utf()
test_utf_to_utf_for<char>();
std::cout << "-- wchar_t\n";
test_utf_to_utf_for<wchar_t>();
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << "-- char8_t\n";
test_utf_to_utf_for<char8_t>();
#endif
@ -643,7 +643,7 @@ void test_latin1_conversions()
test_latin1_conversions_for<char>();
std::cout << "-- wchar_t\n";
test_latin1_conversions_for<wchar_t>();
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << "-- char8_t\n";
test_latin1_conversions_for<char8_t>();
#endif
@ -781,7 +781,7 @@ void test_main(int /*argc*/, char** /*argv*/)
test_utf_for<char>();
std::cout << " wchar_t" << std::endl;
test_utf_for<wchar_t>();
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
test_utf_for<char8_t>();
#endif

View File

@ -329,7 +329,7 @@ void test_main(int /*argc*/, char** /*argv*/)
#else
# define TEST_FOR_CHAR8(check) (void)0
#endif
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
# define TEST_FOR_STRING8(check) TEST(check)
#else
# define TEST_FOR_STRING8(check) (void)0

View File

@ -222,7 +222,7 @@ void test_any_string()
TEST_EQ(s.get<char32_t>(), ascii_to<char32_t>("Char32 Pattern"));
TEST_THROWS(s.get<char16_t>(), std::bad_cast);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
s.set<char8_t>(ascii_to<char8_t>("Char8 Pattern"));
TEST_EQ(s.get<char8_t>(), ascii_to<char8_t>("Char8 Pattern"));
TEST_THROWS(s.get<char32_t>(), std::bad_cast);

View File

@ -84,7 +84,7 @@ std::wstring same_w(std::wstring s)
return s;
}
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::basic_string<char8_t> same_u8(std::basic_string<char8_t> s)
{
return s;
@ -376,7 +376,7 @@ void test_cntranslate(const std::string& c,
impl::test_cntranslate<char>(c, s, p, n, expected, l, domain);
std::cout << " wchar_t" << std::endl;
impl::test_cntranslate<wchar_t>(c, s, p, n, expected, l, domain);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
impl::test_cntranslate<char8_t>(c, s, p, n, expected, l, domain);
#endif
@ -401,7 +401,7 @@ void test_ntranslate(const std::string& s,
impl::test_ntranslate<char>(s, p, n, expected, l, domain);
std::cout << " wchar_t" << std::endl;
impl::test_ntranslate<wchar_t>(s, p, n, expected, l, domain);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
impl::test_ntranslate<char8_t>(s, p, n, expected, l, domain);
#endif
@ -425,7 +425,7 @@ void test_ctranslate(const std::string& c,
impl::test_ctranslate<char>(c, original, expected, l, domain);
std::cout << " wchar_t" << std::endl;
impl::test_ctranslate<wchar_t>(c, original, expected, l, domain);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
impl::test_ctranslate<char8_t>(c, original, expected, l, domain);
#endif
@ -448,7 +448,7 @@ void test_translate(const std::string& original,
impl::test_translate<char>(original, expected, l, domain);
std::cout << " wchar_t" << std::endl;
impl::test_translate<wchar_t>(original, expected, l, domain);
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << " char8_t" << std::endl;
impl::test_translate<char8_t>(original, expected, l, domain);
#endif
@ -570,7 +570,7 @@ void test_main(int argc, char** argv)
TEST_EQ(same_s(bl::translate("hello")), "שלום");
TEST_EQ(same_w(bl::translate(to<wchar_t>("hello"))), to<wchar_t>("שלום"));
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
TEST_EQ(same_u8(bl::translate(to<char8_t>("hello"))), to<char8_t>("שלום"));
#endif
#ifdef BOOST_LOCALE_ENABLE_CHAR16_T

View File

@ -84,7 +84,7 @@ void test_main(int /*argc*/, char** /*argv*/)
test_char<char>();
std::cout << "Testing wchar_t" << std::endl;
test_char<wchar_t>();
#ifndef BOOST_LOCALE_NO_CXX20_STRING8
#ifdef __cpp_lib_char8_t
std::cout << "Testing char8_t" << std::endl;
test_char<char8_t>();
#endif