1[#fail] 2[section fail] 3 4[h1 Synopsis] 5 6 template <class Msg> 7 struct fail; 8 9This is a [link parser parser]. 10 11[table Arguments 12 [[Name] [Type]] 13 [[`Msg`] [[link parsing_error_message parsing error message]]] 14] 15 16[h1 Description] 17 18Parser rejecting every input. 19 20[h1 Header] 21 22 #include <boost/metaparse/fail.hpp> 23 24[h1 Expression semantics] 25 26For any `msg` parsing error message, `s` compile-time string and `pos` source 27position 28 29 fail<msg>::apply<s, pos>::type 30 31returns an error with `msg` as the error message. 32 33[h1 Example] 34 35 #include <boost/metaparse/fail.hpp> 36 #include <boost/metaparse/string.hpp> 37 #include <boost/metaparse/start.hpp> 38 #include <boost/metaparse/is_error.hpp> 39 #include <boost/metaparse/get_message.hpp> 40 #include <boost/metaparse/define_error.hpp> 41 42 using namespace boost::metaparse; 43 44 BOOST_METAPARSE_DEFINE_ERROR(sample_error, "This is an example parsing error"); 45 46 using fail_p = fail<sample_error>; 47 48 static_assert( 49 is_error<fail_p::apply<BOOST_METAPARSE_STRING("foo"), start>>::type::value, 50 "it should reject every input" 51 ); 52 53 static_assert( 54 std::is_same< 55 get_message<fail_p::apply<BOOST_METAPARSE_STRING("foo"), start>>::type, 56 sample_error 57 >::type::value, 58 "the error message should be the type specified" 59 ); 60 61[endsect] 62 63