From 81eb9f952bdf49eb9e62fe7297d162970e83e889 Mon Sep 17 00:00:00 2001 From: Michael Jones Date: Mon, 13 Jul 2026 10:04:33 -0500 Subject: [PATCH] Guard use of char8_t in concepts.hpp with if defined(__cpp_char8_t) --- include/boost/parser/concepts.hpp | 2 ++ include/boost/parser/detail/text/concepts.hpp | 10 ++++++---- .../boost/parser/detail/text/transcode_iterator.hpp | 8 ++++++-- include/boost/parser/detail/text/transcode_view.hpp | 4 ++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/boost/parser/concepts.hpp b/include/boost/parser/concepts.hpp index 296ca92f..cb770515 100644 --- a/include/boost/parser/concepts.hpp +++ b/include/boost/parser/concepts.hpp @@ -22,7 +22,9 @@ namespace boost { namespace parser { concept code_unit = std::same_as, char> || std::same_as, wchar_t> || +#if defined(__cpp_char8_t) std::same_as, char8_t> || +#endif std::same_as, char16_t>|| std::same_as, char32_t>; diff --git a/include/boost/parser/detail/text/concepts.hpp b/include/boost/parser/detail/text/concepts.hpp index 2913dda4..3c025d9d 100644 --- a/include/boost/parser/detail/text/concepts.hpp +++ b/include/boost/parser/detail/text/concepts.hpp @@ -27,11 +27,13 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME #endif template - concept code_unit = (std::same_as && F == format::utf8) || + concept code_unit = (std::same_as && F == format::utf8) || + (std::same_as && F == wchar_t_format) || +#if defined(__cpp_char8_t) + (std::same_as && F == format::utf8) || +#endif (std::same_as && F == format::utf16) || - (std::same_as && F == format::utf32) || - (std::same_as && F == format::utf8) || - (std::same_as && F == wchar_t_format); + (std::same_as && F == format::utf32); template concept utf8_code_unit = code_unit; diff --git a/include/boost/parser/detail/text/transcode_iterator.hpp b/include/boost/parser/detail/text/transcode_iterator.hpp index f979b5a4..ab3f0896 100644 --- a/include/boost/parser/detail/text/transcode_iterator.hpp +++ b/include/boost/parser/detail/text/transcode_iterator.hpp @@ -976,7 +976,7 @@ namespace boost::parser::detail { namespace text { /** An out iterator that converts UTF-32 to UTF-8. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS - template Iter> + template Iter> #else template #endif @@ -1501,7 +1501,7 @@ namespace boost::parser::detail { namespace text { /** An out iterator that converts UTF-16 to UTF-8. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS - template Iter> + template Iter> #else template #endif @@ -2295,11 +2295,13 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 { +#if defined(__cpp_char8_t) template O> constexpr utf_32_to_8_out_iterator utf_32_to_8_out(O it) { return utf_32_to_8_out_iterator(it); } +#endif template O> constexpr utf_8_to_32_out_iterator utf_8_to_32_out(O it) @@ -2319,11 +2321,13 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME return utf_16_to_32_out_iterator(it); } +#if defined(__cpp_char8_t) template O> constexpr utf_16_to_8_out_iterator utf_16_to_8_out(O it) { return utf_16_to_8_out_iterator(it); } +#endif template O> constexpr utf_8_to_16_out_iterator utf_8_to_16_out(O it) diff --git a/include/boost/parser/detail/text/transcode_view.hpp b/include/boost/parser/detail/text/transcode_view.hpp index 275a5273..44d24570 100644 --- a/include/boost/parser/detail/text/transcode_view.hpp +++ b/include/boost/parser/detail/text/transcode_view.hpp @@ -375,8 +375,10 @@ namespace boost::parser::detail { namespace text { }; #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS +#if defined(__cpp_char8_t) template char8_view(R &&) -> char8_view>; +#endif template char16_view(R &&) -> char16_view>; template @@ -413,8 +415,10 @@ namespace boost::parser::detail { namespace text { template constexpr bool is_charn_view = false; #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS +#if defined(__cpp_char8_t) template constexpr bool is_charn_view> = true; +#endif #endif template constexpr bool is_charn_view> = true;