Home | Libraries | People | FAQ | More |
template <class Msg> struct fail;
This is a parser.
Parser rejecting every input.
#include <boost/metaparse/fail.hpp>
For any msg
parsing error
message, s
compile-time
string and pos
source position
fail<msg>::apply<s, pos>::type
returns an error with msg
as the error message.
#include <boost/metaparse/fail.hpp> #include <boost/metaparse/string.hpp> #include <boost/metaparse/start.hpp> #include <boost/metaparse/is_error.hpp> #include <boost/metaparse/get_message.hpp> #include <boost/metaparse/define_error.hpp> using namespace boost::metaparse; BOOST_METAPARSE_DEFINE_ERROR(sample_error, "This is an example parsing error"); using fail_p = fail<sample_error>; static_assert( is_error<fail_p::apply<BOOST_METAPARSE_STRING("foo"), start>>::type::value, "it should reject every input" ); static_assert( std::is_same< get_message<fail_p::apply<BOOST_METAPARSE_STRING("foo"), start>>::type, sample_error >::type::value, "the error message should be the type specified" );