sequence.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef BOOST_METAPARSE_V1_CPP98_SEQUENCE_HPP
  2. #define BOOST_METAPARSE_V1_CPP98_SEQUENCE_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2010.
  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/v1/cpp98/impl/sequence.hpp>
  8. #include <boost/preprocessor/comma_if.hpp>
  9. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  10. #include <boost/preprocessor/repetition/enum.hpp>
  11. #include <boost/preprocessor/repetition/enum_params.hpp>
  12. #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
  13. #include <boost/preprocessor/arithmetic/sub.hpp>
  14. #include <boost/preprocessor/cat.hpp>
  15. #include <boost/preprocessor/tuple/eat.hpp>
  16. namespace boost
  17. {
  18. namespace metaparse
  19. {
  20. namespace v1
  21. {
  22. template <
  23. BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
  24. BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE,
  25. class P,
  26. boost::mpl::na
  27. )
  28. >
  29. struct sequence;
  30. #ifdef BOOST_METAPARSE_SEQUENCE_N
  31. # error BOOST_METAPARSE_SEQUENCE_N already defined
  32. #endif
  33. #define BOOST_METAPARSE_SEQUENCE_N(z, n, unused) \
  34. template <BOOST_PP_ENUM_PARAMS(n, class P)> \
  35. struct sequence< \
  36. BOOST_PP_ENUM_PARAMS(n, P) \
  37. BOOST_PP_COMMA_IF(n) \
  38. BOOST_PP_ENUM( \
  39. BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, n), \
  40. boost::mpl::na BOOST_PP_TUPLE_EAT(3), \
  41. ~ \
  42. ) \
  43. > : impl::BOOST_PP_CAT(sequence, n)<BOOST_PP_ENUM_PARAMS(n, P)> \
  44. {};
  45. BOOST_PP_REPEAT_FROM_TO(
  46. 1,
  47. BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE,
  48. BOOST_METAPARSE_SEQUENCE_N,
  49. ~
  50. )
  51. #undef BOOST_METAPARSE_SEQUENCE_N
  52. }
  53. }
  54. }
  55. #endif