is_none.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef BOOST_METAPARSE_V1_CPP98_IMPL_IS_NONE_HPP
  2. #define BOOST_METAPARSE_V1_CPP98_IMPL_IS_NONE_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
  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 <boost/metaparse/limit_one_char_except_size.hpp>
  8. #include <boost/mpl/eval_if.hpp>
  9. #include <boost/mpl/bool.hpp>
  10. #include <boost/preprocessor/cat.hpp>
  11. #include <boost/preprocessor/arithmetic/dec.hpp>
  12. #include <boost/preprocessor/repetition/enum_params.hpp>
  13. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  14. namespace boost
  15. {
  16. namespace metaparse
  17. {
  18. namespace v1
  19. {
  20. namespace impl
  21. {
  22. template <class Stub = int>
  23. struct is_none0
  24. {
  25. template <class C>
  26. struct apply : boost::mpl::true_ {};
  27. };
  28. #ifdef BOOST_METAPARSE_DEFINE_IS_NONE
  29. # error BOOST_METAPARSE_DEFINE_IS_NONE already defined
  30. #endif
  31. #define BOOST_METAPARSE_DEFINE_IS_NONE(z, n, unused) \
  32. template <BOOST_PP_ENUM_PARAMS(n, class T)> \
  33. struct BOOST_PP_CAT(is_none, n) \
  34. { \
  35. template <class C> \
  36. struct apply : \
  37. boost::mpl::eval_if< \
  38. boost::mpl::bool_< \
  39. C::type::value \
  40. == BOOST_PP_CAT(T, BOOST_PP_DEC(n))::type::value \
  41. >, \
  42. boost::mpl::false_, \
  43. typename BOOST_PP_CAT(is_none, BOOST_PP_DEC(n))< \
  44. BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(n), T) \
  45. >::template apply<C> \
  46. > \
  47. {}; \
  48. };
  49. BOOST_PP_REPEAT_FROM_TO(
  50. 1,
  51. BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE,
  52. BOOST_METAPARSE_DEFINE_IS_NONE,
  53. ~
  54. )
  55. #undef BOOST_METAPARSE_DEFINE_IS_NONE
  56. }
  57. }
  58. }
  59. }
  60. #endif