1[#before_5_2_2] 2['Definitions before section 5.2.2.] 3 4 #include <boost/metaparse/string.hpp> 5 #include <boost/metaparse/int_.hpp> 6 7 #include <boost/metaparse/build_parser.hpp> 8 9 using namespace boost::metaparse; 10 11 using exp_parser1 = build_parser<int_>; 12 #include <boost/metaparse/entire_input.hpp> 13 14 using exp_parser2 = build_parser<entire_input<int_>>; 15 #include <boost/metaparse/token.hpp> 16 17 using exp_parser3 = build_parser<entire_input<token<int_>>>; 18 #include <boost/metaparse/lit_c.hpp> 19 20 #include <boost/metaparse/sequence.hpp> 21 22 using exp_parser4 = build_parser<sequence<token<int_>, token<lit_c<'+'>>, token<int_>>>; 23 24 #include <metashell/formatter.hpp> 25 26 using int_token = token<int_>; 27 28 using plus_token = token<lit_c<'+'>>; 29 30 using exp_parser5 = build_parser<sequence<int_token, plus_token, int_token>>; 31 #include <boost/metaparse/transform.hpp> 32 33 #include <boost/mpl/plus.hpp> 34 35 #include <boost/mpl/at.hpp> 36 37 template <class Vector> 38 struct eval_plus : 39 boost::mpl::plus< 40 typename boost::mpl::at_c<Vector, 0>::type, 41 typename boost::mpl::at_c<Vector, 2>::type 42 > {}; 43 44 #include <boost/mpl/quote.hpp> 45 46 using exp_parser6 = 47 build_parser< 48 transform< 49 sequence<int_token, plus_token, int_token>, 50 boost::mpl::quote1<eval_plus> 51 > 52 >; 53 #include <boost/metaparse/any.hpp> 54 55 using exp_parser7 = 56 build_parser< 57 sequence< 58 int_token, /* The first <number> */ 59 repeated<sequence<plus_token, int_token>> /* The "+ <number>" elements */ 60 > 61 >; 62 using temp_result = exp_parser7::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type; 63 #include <boost/mpl/fold.hpp> 64 65 using vector_of_numbers = 66 boost::mpl::vector< 67 boost::mpl::int_<2>, 68 boost::mpl::int_<5>, 69 boost::mpl::int_<6> 70 >; 71 72 template <class Vector> 73 struct sum_vector : 74 boost::mpl::fold< 75 Vector, 76 boost::mpl::int_<0>, 77 boost::mpl::lambda< 78 boost::mpl::plus<boost::mpl::_1, boost::mpl::_2> 79 >::type 80 > 81 {}; 82 83 template <class Sum, class Item> 84 struct sum_items : 85 boost::mpl::plus< 86 Sum, 87 typename boost::mpl::at_c<Item, 1>::type 88 > 89 {}; 90 91