1[#one_char_except] 2[section one_char_except] 3 4[h1 Synopsis] 5 6 template <class... Cs> 7 struct one_char_except; 8 9This is a [link parser parser]. 10 11[table Arguments 12 [[Name] [Type]] 13 [[`Cs`] [[link boxed_value boxed] character values]] 14] 15 16[h1 Description] 17 18`one_char_except` accepts one character except any of `Cs`. When the input is 19empty or begins with one of the non-accepted characters, `one_char_except` 20rejects the input. Otherwise it accepts the input and the result of parsing is 21the character value. 22 23On compilers, which are not C++11-compliant, the maximum number of characters 24this class can have is the value the macro 25`BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE` expands to. Its default value is 2610. 27 28[h1 Header] 29 30 #include <boost/metaparse/one_char_except.hpp> 31 32[h1 Expression semantics] 33 34For any `c1`, ..., `cn` boxed characters the following are equivalent 35 36 one_char_except<c1, ..., cn> 37 38 one_char_except_c<c1::type::value, ..., cn::type::value> 39 40[h1 Example] 41 42 #include <boost/metaparse/one_char_except.hpp> 43 #include <boost/metaparse/lit_c.hpp> 44 #include <boost/metaparse/middle_of.hpp> 45 #include <boost/metaparse/repeated.hpp> 46 #include <boost/metaparse/start.hpp> 47 #include <boost/metaparse/string.hpp> 48 #include <boost/metaparse/get_result.hpp> 49 50 #include <boost/mpl/vector.hpp> 51 #include <boost/mpl/char.hpp> 52 #include <boost/mpl/equal.hpp> 53 54 #include <type_traits> 55 56 using namespace boost::metaparse; 57 58 using string_literal_parser = 59 middle_of< 60 lit_c<'"'>, 61 repeated<one_char_except<std::integral_constant<char, '"'>>>, 62 lit_c<'"'> 63 >; 64 65 static_assert( 66 boost::mpl::equal< 67 boost::mpl::vector< 68 boost::mpl::char_<'h'>, 69 boost::mpl::char_<'e'>, 70 boost::mpl::char_<'l'>, 71 boost::mpl::char_<'l'>, 72 boost::mpl::char_<'o'> 73 >, 74 get_result< 75 string_literal_parser::apply<BOOST_METAPARSE_STRING("\"hello\""), start> 76 >::type 77 >::type::value, 78 "it should return the content of the string literal" 79 ); 80 81[endsect] 82 83