diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 1c5585f3..08cce2b3 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -4587,7 +4587,13 @@ namespace boost { namespace parser { !std::is_same_v) && std::is_assignable_v && (!std::is_same_v || - !std::is_integral_v)) { + !std::is_integral_v) && + (!std::is_integral_v || + (!std::is_same_v +#if defined(__cpp_char8_t) + && !std::is_same_v +#endif + ))) { detail::assign(out, std::move(x)); } else { detail::move_back( diff --git a/test/github_issues.cpp b/test/github_issues.cpp index 03dd3099..c9c11619 100644 --- a/test/github_issues.cpp +++ b/test/github_issues.cpp @@ -777,6 +777,48 @@ void github_issue_312() BOOST_TEST(result.value()->evaluate() == ((2*0.1) + 33.) * (2 + 3) + 3.1415 * 2); } +void github_issue_327() +{ + namespace bp = boost::parser; + auto const chars = bp::char_ >> bp::char_; + + { + std::u32string result; + bool const success = bp::parse(std::u32string{U"ab"}, chars, result); + BOOST_TEST(success); + BOOST_TEST(result == U"ab"); + } + { + std::u32string result; + bool const success = bp::parse(std::string{"ab"}, chars, result); + BOOST_TEST(success); + BOOST_TEST(result == U"ab"); + } + { + std::u32string const input{U"\u00e9\U0001F600"}; + std::u32string result; + bool const success = bp::parse(input, chars, result); + BOOST_TEST(success); + BOOST_TEST(result == input); + } + { + std::u32string const input{U"\u00e9\U0001F600"}; + std::string result; + bool const success = bp::parse(input, chars, result); + BOOST_TEST(success); + BOOST_TEST(result == "\xC3\xA9\xF0\x9F\x98\x80"); + } +#if defined(__cpp_char8_t) + { + std::u32string const input{U"\u00e9\U0001F600"}; + std::u8string result; + bool const success = bp::parse(input, chars, result); + BOOST_TEST(success); + BOOST_TEST(result == u8"\u00e9\U0001F600"); + } +#endif +} + int main() { @@ -796,5 +838,6 @@ int main() github_issue_294(); github_pr_297(); github_issue_312(); + github_issue_327(); return boost::report_errors(); }