[#transform_error] [section transform_error] [h1 Synopsis] template struct transform_error; This is a [link parser_combinator parser combinator]. [table Arguments [[Name] [Type]] [[`P`] [[link parser parser]]] [[`F`] [[link metafunction_class template metafunction class] taking one argument]] ] [h1 Description] It parses the input with `P`. When this succeeds, the result of parsing with `transform_error` will be the result of parsing with `P`. When it fails, `F` is evaluated with the error `P` returned as argument. Parsing with `transform_error` will fail and the error will be what `F` returns. Therefore, `F` is expected to accept and return a [link reject `reject`] value. [h1 Header] #include [h1 Expression semantics] For any `p` parser and `f` metafunction class accepting one argument transform_error::apply is equivalent to `p::apply` when `p` accepts the input. It is equivalent to `f::apply::type>` otherwise. [h1 Example] #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace boost::metaparse; BOOST_METAPARSE_DEFINE_ERROR(name_expected, "Name expected"); using keyword_name = token>; using name_token = token>; using name_parser = last_of< keyword_name, transform_error< name_token, boost::mpl::lambda< reject > >::type > >; static_assert( !is_error< name_parser::apply >::type::value, "name_parser should accept \"name \"" ); static_assert( is_error< name_parser::apply >::type::value, "name_parser should reject input when name is a question mark" ); static_assert( std::is_same< get_message< name_parser::apply >::type, name_expected >::type::value, "the error message should be the one specified by change_error_message" ); [endsect]