6 template <char C, class T>
9 This is a [link parser_combinator parser combinator].
14 [[`T`] [[link metaprogramming_value template metaprogramming value]]]
19 It accepts inputs beginning with the `C` character. It consumes that character
20 and the result of parsing is `T`. Other inputs as rejected.
24 #include <boost/metaparse/always_c.hpp>
26 [h1 Expression semantics]
28 For any `c` character and `t` class the following are equivalent:
36 #include <boost/metaparse/always_c.hpp>
37 #include <boost/metaparse/start.hpp>
38 #include <boost/metaparse/string.hpp>
39 #include <boost/metaparse/is_error.hpp>
40 #include <boost/metaparse/get_result.hpp>
42 #include <type_traits>
44 using namespace boost::metaparse;
46 using always13 = always_c<'x', std::integral_constant<int, 13>>;
49 !is_error<always13::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
50 "always13 should accept x"
55 get_result<always13::apply<BOOST_METAPARSE_STRING("x"), start>>::type,
56 std::integral_constant<int, 13>
58 "the result of parsing should be the integral_constant type"
62 is_error<always13::apply<BOOST_METAPARSE_STRING("y"), start>>::type::value,
63 "always13 should reject characters other than x"