• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_METAPARSE_GETTING_STARTED_7_HPP
2 #define BOOST_METAPARSE_GETTING_STARTED_7_HPP
3 
4 // Automatically generated header file
5 
6 // Definitions before section 6.2
7 #include "6_2.hpp"
8 
9 // Definitions of section 6.2
10 #include <boost/mpl/minus.hpp>
11 
12 template <class L, char Op, class R> struct eval_binary_op;
13 
14 template <class L, class R> struct eval_binary_op<L, '+', R> : boost::mpl::plus<L, R>::type {};
15 
16 template <class L, class R> struct eval_binary_op<L, '-', R> : boost::mpl::minus<L, R>::type {};
17 
18 // query:
19 //    eval_binary_op<boost::mpl::int_<11>, '+', boost::mpl::int_<2>>::type
20 
21 // query:
22 //    eval_binary_op<boost::mpl::int_<13>, '-', boost::mpl::int_<2>>::type
23 
24 template <class S, class Item>
25  struct binary_op :
26    eval_binary_op<
27      S,
28      boost::mpl::at_c<Item, 0>::type::value,
29      typename boost::mpl::at_c<Item, 1>::type
30    >
31    {};
32 
33 // query:
34 //    binary_op<boost::mpl::int_<11>, boost::mpl::vector<boost::mpl::char_<'+'>, boost::mpl::int_<2>>>::type
35 
36 using exp_parser13 =
37  build_parser<
38    foldl_start_with_parser<
39      sequence<one_of<plus_token, minus_token>, int_token>,
40      int_token,
41      boost::mpl::quote2<binary_op>
42    >
43  >;
44 
45 // query:
46 //    exp_parser13::apply<BOOST_METAPARSE_STRING("1 + 2 - 3")>::type
47 
48 #endif
49 
50