1[#build_parser] 2[section build_parser] 3 4[h1 Synopsis] 5 6 template <class P> 7 struct build_parser; 8 9This is a [link metafunction template metafunction]. 10 11[table Arguments 12 [[Name] [Type]] 13 [[`P`] [[link parser parser]]] 14] 15 16[h1 Description] 17 18It generates a simple interface for parser. It returns a metafunction class that 19takes an input string, parses it with `P` and returns the result of parsing. It 20generates a compilation error when parsing fails. 21 22[h1 Return value] 23 24It returns a [link metafunction_class template metafunction class]: 25 26 struct 27 { 28 template <class S> 29 struct apply; 30 }; 31 32[table Arguments 33 [[Name] [Type]] 34 [[`S`] [[link string string]]] 35] 36 37[h1 Header] 38 39 #include <boost/metaparse/build_parser.hpp> 40 41[h1 Expression semantics] 42 43For any `p` parser and `s` compile-time string 44 45 build_parser<p>::type::apply<s> 46 47is equivalent to 48 49 get_result<p::apply<s>> 50 51[h1 Example] 52 53 #include <boost/metaparse/build_parser.hpp> 54 #include <boost/metaparse/int_.hpp> 55 #include <boost/metaparse/string.hpp> 56 57 using namespace boost::metaparse; 58 59 using string_to_int = build_parser<int_>::type; 60 61 static_assert( 62 string_to_int::apply<BOOST_METAPARSE_STRING("1113")>::type::value == 1113, 63 "string_to_int should be a metafunction turning a string into an int" 64 ); 65 66[endsect] 67 68