1 [#BOOST_METAPARSE_DEFINE_ERROR]
2 [section BOOST_METAPARSE_DEFINE_ERROR]
6 #define BOOST_METAPARSE_DEFINE_ERROR(name, msg) \
13 [[`name`] [identifier token]]
14 [[`msg`] [string literal]]
19 Macro for defining a [link parsing_error_message parsing error message] class.
20 `name` is the name of the class representing the error message and `msg` is a
21 string literal containing the description of the error.
25 #include <boost/metaparse/define_error.hpp>
27 [h1 Expression semantics]
29 For any `n` name and `m` string literal, given the following is defined:
31 BOOST_METAPARSE_DEFINE_ERROR(n, m);
33 the following pairs of expressions are equivalent:
43 #include <boost/metaparse/define_error.hpp>
44 #include <boost/metaparse/repeated1.hpp>
45 #include <boost/metaparse/letter.hpp>
46 #include <boost/metaparse/int_.hpp>
47 #include <boost/metaparse/token.hpp>
48 #include <boost/metaparse/sequence.hpp>
49 #include <boost/metaparse/change_error_message.hpp>
50 #include <boost/metaparse/start.hpp>
51 #include <boost/metaparse/get_message.hpp>
52 #include <boost/metaparse/string.hpp>
54 #include <type_traits>
56 using namespace boost::metaparse;
58 BOOST_METAPARSE_DEFINE_ERROR(age_expected, "Age expected");
60 using name_token = token<repeated1<letter>>;
61 using age_token = token<change_error_message<int_, age_expected>>;
63 using name_age = sequence<name_token, age_token>;
68 get_message<name_age::apply<BOOST_METAPARSE_STRING("Joe "), start>>::type
70 "the error message should be age_expected when the age is missing"