meta_hs.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef META_HS_META_HS_HPP
  2. #define META_HS_META_HS_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2012.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <builder.hpp>
  8. #include <boost/mpl/plus.hpp>
  9. #include <boost/mpl/minus.hpp>
  10. #include <boost/mpl/times.hpp>
  11. #include <boost/mpl/divides.hpp>
  12. #include <boost/mpl/less.hpp>
  13. #include <boost/mpl/less_equal.hpp>
  14. #include <boost/mpl/greater.hpp>
  15. #include <boost/mpl/greater_equal.hpp>
  16. #include <boost/mpl/equal_to.hpp>
  17. #include <boost/mpl/not_equal_to.hpp>
  18. #include <boost/preprocessor/cat.hpp>
  19. #include <boost/preprocessor/seq/for_each.hpp>
  20. #ifdef DEFINE_LAZY
  21. #error DEFINE_LAZY already defined
  22. #endif
  23. #define DEFINE_LAZY(r, unused, name) \
  24. template <class A, class B> \
  25. struct BOOST_PP_CAT(lazy_, name) : \
  26. boost::mpl::name<typename A::type, typename B::type> \
  27. {};
  28. BOOST_PP_SEQ_FOR_EACH(DEFINE_LAZY, ~,
  29. (plus)
  30. (minus)
  31. (times)
  32. (divides)
  33. (less)
  34. (less_equal)
  35. (greater)
  36. (greater_equal)
  37. (equal_to)
  38. (not_equal_to)
  39. )
  40. #undef DEFINE_LAZY
  41. typedef builder<>
  42. ::import2<boost::metaparse::string<'.','+','.'>, lazy_plus>::type
  43. ::import2<boost::metaparse::string<'.','-','.'>, lazy_minus>::type
  44. ::import2<boost::metaparse::string<'.','*','.'>, lazy_times>::type
  45. ::import2<boost::metaparse::string<'.','/','.'>, lazy_divides>::type
  46. ::import2<boost::metaparse::string<'.','<','.'>, lazy_less>::type
  47. ::import2<boost::metaparse::string<'.','<','=','.'>, lazy_less_equal>::type
  48. ::import2<boost::metaparse::string<'.','>','.'>, lazy_greater>::type
  49. ::import2<boost::metaparse::string<'.','>','=','.'>, lazy_greater_equal>::type
  50. ::import2<boost::metaparse::string<'.','=','=','.'>, lazy_equal_to>::type
  51. ::import2<boost::metaparse::string<'.','/','=','.'>, lazy_not_equal_to>::type
  52. meta_hs;
  53. #endif