diff --git a/include/boost/spirit/home/x3/string/symbols.hpp b/include/boost/spirit/home/x3/string/symbols.hpp index 2d00944be2..2fc1623203 100644 --- a/include/boost/spirit/home/x3/string/symbols.hpp +++ b/include/boost/spirit/home/x3/string/symbols.hpp @@ -36,11 +36,22 @@ namespace boost { namespace spirit { namespace x3 { + template < typename Encoding > + struct get_default_symbol_filter + { + template + static auto get(Context const& context) -> decltype(get_case_compare(context)) + { + return {}; + } + }; + template < typename Encoding , typename T = unused_type + , typename GetFilter = get_default_symbol_filter , typename Lookup = tst > - struct symbols_parser : parser> + struct symbols_parser : parser> { typedef typename Encoding::char_type char_type; // the character type typedef Encoding encoding; @@ -220,7 +231,7 @@ namespace boost { namespace spirit { namespace x3 x3::skip_over(first, last, context); if (value_type* val_ptr - = lookup->find(first, last, get_case_compare(context))) + = lookup->find(first, last, GetFilter::get(context))) { x3::traits::move_to(*val_ptr, attr); return true; diff --git a/test/x3/Jamfile b/test/x3/Jamfile index 2809cb131a..d3023c348d 100644 --- a/test/x3/Jamfile +++ b/test/x3/Jamfile @@ -126,6 +126,7 @@ rule compile-fail ( sources + : requirements * : target-name ? ) [ run symbols1.cpp : : : : x3_symbols1 ] [ run symbols2.cpp : : : : x3_symbols2 ] [ run symbols3.cpp : : : : x3_symbols3 ] + [ run symbols4.cpp : : : : x3_symbols4 ] #~ [ run terminal_ex.cpp : : : : x3_terminal_ex ] [ run tst.cpp $(BOOST_ROOT)/libs/system/build//boost_system diff --git a/test/x3/symbols4.cpp b/test/x3/symbols4.cpp new file mode 100644 index 0000000000..603b55db16 --- /dev/null +++ b/test/x3/symbols4.cpp @@ -0,0 +1,60 @@ +/*============================================================================= + Copyright (c) 2015 Thomas Bernard + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#include +#include + +#include "test.hpp" + + +#include + + namespace braille { + namespace encoding { + struct dots + { + using char_type = char32_t; + }; + } + + template + struct dots_compare + { + int32_t operator()( + typename Encoding::char_type const lc + , typename Encoding::char_type const rc) const + { + // do magic here + return lc - rc; + } + + }; + + struct get_dots_compare + { + template + static dots_compare get(Context const& context) + { + return {}; + } + }; + } + + namespace braille { + template + using symbols = boost::spirit::x3::symbols_parser; + } + + int main() + { + using spirit_test::test; + { + braille::symbols<> syms; + syms.add(U"\u2800"); + BOOST_TEST((test(U"\u2800", syms))); + } + return boost::report_errors(); + }