2 [section one_char_except_c]
6 template <char C1, char C2, /* ... */, char Cn>
7 struct one_char_except_c;
9 This is a [link parser parser].
13 [[`C1`..`Cn`] [character values]]
18 `one_char_except_c` accepts one character except any of `C1` ... `Cn`. When the
19 input is empty or begins with one of the non-accepted characters,
20 `one_char_except_c` rejects the input. Otherwise it accepts the input and the
21 result of parsing is the character value.
23 The maximum number of template arguments this class can have is the value the
24 macro `BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE` expands to. Its default value
29 #include <boost/metaparse/one_char_except_c.hpp>
31 [h1 Expression semantics]
33 For any `s` compile-time string and `c1`, ..., `cn` characters the following are
36 one_char_except_c<c1, ..., cn>::apply<s, pos>
38 boost::metaparse::one_char::apply<s, pos>
40 when `s` is empty or it begins with a character other than `c1`, ..., `cn`.
41 Otherwise `one_char_except_c<c1, ..., cn>::appl<s, pos>` returns a parsing
46 #include <boost/metaparse/one_char_except_c.hpp>
47 #include <boost/metaparse/lit_c.hpp>
48 #include <boost/metaparse/middle_of.hpp>
49 #include <boost/metaparse/repeated.hpp>
50 #include <boost/metaparse/start.hpp>
51 #include <boost/metaparse/string.hpp>
52 #include <boost/metaparse/get_result.hpp>
54 #include <boost/mpl/vector.hpp>
55 #include <boost/mpl/char.hpp>
56 #include <boost/mpl/equal.hpp>
58 using namespace boost::metaparse;
60 using string_literal_parser =
61 middle_of<lit_c<'"'>, repeated<one_char_except_c<'"'>>, lit_c<'"'>>;
66 boost::mpl::char_<'h'>,
67 boost::mpl::char_<'e'>,
68 boost::mpl::char_<'l'>,
69 boost::mpl::char_<'l'>,
70 boost::mpl::char_<'o'>
73 string_literal_parser::apply<BOOST_METAPARSE_STRING("\"hello\""), start>
76 "it should return the content of the string literal"