6 template <class P, class T>
9 This is a [link parser_combinator parser combinator].
13 [[`P`] [[link parser parser]]]
14 [[`T`] [[link metaprogramming_value template metaprogramming value]]]
19 It accepts an input if and only if `P` accepts it, but the result of parsing
20 will be `T` instead of the result `P` returned.
24 #include <boost/metaparse/always.hpp>
26 [h1 Expression semantics]
28 For any `p` parser and `t` class the following are equivalent:
32 last_of<p, return_<t>>
36 #include <boost/metaparse/always.hpp>
37 #include <boost/metaparse/lit_c.hpp>
38 #include <boost/metaparse/start.hpp>
39 #include <boost/metaparse/string.hpp>
40 #include <boost/metaparse/is_error.hpp>
41 #include <boost/metaparse/get_result.hpp>
43 #include <type_traits>
45 using namespace boost::metaparse;
47 using always13 = always<lit_c<'x'>, std::integral_constant<int, 13>>;
50 !is_error<always13::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
51 "always13 should accept x"
56 get_result<always13::apply<BOOST_METAPARSE_STRING("x"), start>>::type,
57 std::integral_constant<int, 13>
59 "the result of parsing should be the integral_constant type"
63 is_error<always13::apply<BOOST_METAPARSE_STRING("y"), start>>::type::value,
64 "always13 should reject characters other than x"