7.hpp 1.2 KB

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