]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_METAPARSE_V1_LAST_OF_HPP |
2 | #define BOOST_METAPARSE_V1_LAST_OF_HPP | |
3 | ||
4 | // Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2010. | |
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/nth_of.hpp> | |
10 | ||
11 | #include <boost/preprocessor/cat.hpp> | |
12 | #include <boost/preprocessor/punctuation/comma_if.hpp> | |
13 | #include <boost/preprocessor/repetition/enum_params.hpp> | |
14 | #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> | |
15 | #include <boost/preprocessor/repetition/enum.hpp> | |
16 | #include <boost/preprocessor/repetition/repeat.hpp> | |
17 | #include <boost/preprocessor/arithmetic/sub.hpp> | |
18 | #include <boost/preprocessor/tuple/eat.hpp> | |
19 | ||
20 | namespace boost | |
21 | { | |
22 | namespace metaparse | |
23 | { | |
24 | namespace v1 | |
25 | { | |
26 | template < | |
27 | BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( | |
28 | BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, | |
29 | class P, | |
30 | boost::mpl::na | |
31 | ) | |
32 | > | |
33 | struct last_of; | |
34 | ||
35 | #ifdef BOOST_METAPARSE_LAST_OF_N | |
36 | # error BOOST_METAPARSE_LAST_OF_N already defined | |
37 | #endif | |
38 | #define BOOST_METAPARSE_LAST_OF_N(z, n, unused) \ | |
39 | template <BOOST_PP_ENUM_PARAMS(n, class P)> \ | |
40 | struct last_of< \ | |
41 | BOOST_PP_ENUM_PARAMS(n, P) \ | |
42 | BOOST_PP_COMMA_IF(n) \ | |
43 | BOOST_PP_ENUM( \ | |
44 | BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, n), \ | |
45 | boost::mpl::na BOOST_PP_TUPLE_EAT(3), \ | |
46 | ~ \ | |
47 | ) \ | |
48 | > : \ | |
49 | impl::BOOST_PP_CAT(nth_of_c, n)< \ | |
50 | n - 1 BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, P) \ | |
51 | > \ | |
52 | {}; | |
53 | ||
54 | BOOST_PP_REPEAT( | |
55 | BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, | |
56 | BOOST_METAPARSE_LAST_OF_N, | |
57 | ~ | |
58 | ) | |
59 | ||
60 | #undef BOOST_METAPARSE_LAST_OF_N | |
61 | } | |
62 | } | |
63 | } | |
64 | ||
65 | #endif | |
66 |