Home | Libraries | People | FAQ | More |
template <class C> struct return_;
This is a parser.
return_
accepts every input.
The result of parsing is C
,
the remaining string is the input string.
#include <boost/metaparse/return_.hpp>
For any c
class, s
compile-time string and pos
source position the following are
equivalent
get_result<return_<c>::apply<s, pos>>::type c get_remaining<return_<c>::apply<s, pos>>::type s get_position<return_<c>::apply<s, pos>>::type pos
#include <boost/metaparse/return_.hpp> #include <boost/metaparse/int_.hpp> #include <boost/metaparse/one_of.hpp> #include <boost/metaparse/start.hpp> #include <boost/metaparse/string.hpp> #include <boost/metaparse/get_result.hpp> #include <type_traits> using namespace boost::metaparse; using default_value = std::integral_constant<int, 13>; using optional_number = one_of<int_, return_<default_value>>; static_assert( get_result< optional_number::apply<BOOST_METAPARSE_STRING("11"), start> >::type::value == 11, "when a number is provided, it is the result of parsing" ); static_assert( get_result< optional_number::apply<BOOST_METAPARSE_STRING(""), start> >::type::value == 13, "when no number is provided, the default value is the result of parsing" );