]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_METAPARSE_V1_NTH_OF_C_HPP |
2 | #define BOOST_METAPARSE_V1_NTH_OF_C_HPP | |
3 | ||
4 | // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. | |
5 | // Distributed under the Boost Software License, Version 1.0. | |
6 | // (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | #include <boost/metaparse/v1/impl/nth_of_c.hpp> | |
10 | #include <boost/metaparse/limit_sequence_size.hpp> | |
11 | ||
12 | #include <boost/preprocessor/repetition/repeat.hpp> | |
13 | #include <boost/preprocessor/repetition/enum.hpp> | |
14 | #include <boost/preprocessor/punctuation/comma_if.hpp> | |
15 | #include <boost/preprocessor/repetition/enum_params.hpp> | |
16 | #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> | |
17 | #include <boost/preprocessor/arithmetic/sub.hpp> | |
18 | #include <boost/preprocessor/cat.hpp> | |
19 | #include <boost/preprocessor/tuple/eat.hpp> | |
20 | ||
21 | namespace boost | |
22 | { | |
23 | namespace metaparse | |
24 | { | |
25 | namespace v1 | |
26 | { | |
27 | template < | |
28 | int N, | |
29 | BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( | |
30 | BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, | |
31 | class P, | |
32 | boost::mpl::na | |
33 | ) | |
34 | > | |
35 | struct nth_of_c; | |
36 | ||
37 | #ifdef BOOST_METAPARSE_NTH_OF_N | |
38 | # error BOOST_METAPARSE_NTH_OF_N already defined | |
39 | #endif | |
40 | #define BOOST_METAPARSE_NTH_OF_N(z, n, unused) \ | |
41 | template <int K BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class P)> \ | |
42 | struct nth_of_c< \ | |
43 | K, \ | |
44 | BOOST_PP_ENUM_PARAMS(n, P) \ | |
45 | BOOST_PP_COMMA_IF(n) \ | |
46 | BOOST_PP_ENUM( \ | |
47 | BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, n), \ | |
48 | boost::mpl::na BOOST_PP_TUPLE_EAT(3), \ | |
49 | ~ \ | |
50 | ) \ | |
51 | > : \ | |
52 | impl::BOOST_PP_CAT(nth_of_c, n)< \ | |
53 | K BOOST_PP_COMMA_IF(n) \ | |
54 | BOOST_PP_ENUM_PARAMS(n, P) \ | |
55 | > \ | |
56 | {}; | |
57 | ||
58 | BOOST_PP_REPEAT( | |
59 | BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, | |
60 | BOOST_METAPARSE_NTH_OF_N, | |
61 | ~ | |
62 | ) | |
63 | ||
64 | #undef BOOST_METAPARSE_NTH_OF_N | |
65 | } | |
66 | } | |
67 | } | |
68 | ||
69 | #endif | |
70 |