From c2429a818183ce6efa9812ceed71b4d305276591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Fri, 19 Feb 2021 09:19:27 +0100 Subject: [PATCH] allow ascii symbols_parser to be matched against unicode chars --- include/boost/spirit/home/x3/support/no_case.hpp | 8 ++++---- test/x3/symbols3.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/boost/spirit/home/x3/support/no_case.hpp b/include/boost/spirit/home/x3/support/no_case.hpp index 48c06d6f34..7d772d4727 100644 --- a/include/boost/spirit/home/x3/support/no_case.hpp +++ b/include/boost/spirit/home/x3/support/no_case.hpp @@ -24,8 +24,8 @@ namespace boost { namespace spirit { namespace x3 return set.test(ch); } - template - int32_t operator()(Char lc, Char rc) const + template + int32_t operator()(Char lc, Char2 rc) const { return lc - rc; } @@ -50,8 +50,8 @@ namespace boost { namespace spirit { namespace x3 ? Encoding::toupper(ch) : Encoding::tolower(ch)); } - template - int32_t operator()(Char lc_, Char const rc_) const + template + int32_t operator()(Char lc_, Char2 const rc_) const { using char_type = typename Encoding::classify_type; auto lc = char_type(lc_); diff --git a/test/x3/symbols3.cpp b/test/x3/symbols3.cpp index bace674dc6..07d6b27229 100644 --- a/test/x3/symbols3.cpp +++ b/test/x3/symbols3.cpp @@ -93,5 +93,15 @@ main() BOOST_TEST(r == 3); } + { // unicode input | ascii symbols + using namespace boost::spirit; + symbols foo = {{"a1", 1}, {"a2", 2}, {"a3", 3}}; + + int r; + BOOST_TEST((test_attr(U"a3", foo, r))); + std::cout << "r = " <