6 template <class S, class ResultType = /* unspecified */>
9 This is a [link parser parser].
13 [[`S`] [[link string string]]]
14 [[`ResultType`] [[link metaprogramming_value template metaprogramming value]]]
19 Parser accepting the keyword `S`. The result of parsing is `ResultType`, which
20 is optional; when not given, the result of successful parsing is undefined.
24 #include <boost/metaparse/keyword.hpp>
26 [h1 Expression semantics]
28 For any `r` class and `s` compile-time string that is built from the characters
29 `c1` ... `cn` the following are equivalent:
33 last_of<lit<c1>, /* ... */, lit<cn>, return_<r>>
37 #include <boost/metaparse/keyword.hpp>
38 #include <boost/metaparse/string.hpp>
39 #include <boost/metaparse/start.hpp>
40 #include <boost/metaparse/get_result.hpp>
41 #include <boost/metaparse/is_error.hpp>
43 #include <type_traits>
45 using namespace boost::metaparse;
49 keyword<BOOST_METAPARSE_STRING("for"), std::integral_constant<int, 13>>
50 ::apply<BOOST_METAPARSE_STRING("for"), start>
52 "the result of parsing the keyword is keyword's second argument"
57 keyword<BOOST_METAPARSE_STRING("for"), std::integral_constant<int, 13>>
58 ::apply<BOOST_METAPARSE_STRING("if"), start>
60 "a word other than the keyword is an error"