1 #ifndef BOOST_METAPARSE_V1_CPP98_IMPL_NTH_OF_C_HPP
2 #define BOOST_METAPARSE_V1_CPP98_IMPL_NTH_OF_C_HPP
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)
9 #include <boost/metaparse/v1/cpp98/impl/nth_of_c_impl.hpp>
10 #include <boost/metaparse/v1/error/index_out_of_range.hpp>
11 #include <boost/metaparse/v1/fail.hpp>
12 #include <boost/metaparse/limit_sequence_size.hpp>
14 #include <boost/mpl/list.hpp>
16 #include <boost/preprocessor/repetition/repeat.hpp>
17 #include <boost/preprocessor/punctuation/comma_if.hpp>
18 #include <boost/preprocessor/repetition/enum_params.hpp>
19 #include <boost/preprocessor/cat.hpp>
29 #ifdef BOOST_METAPARSE_NTH_OF_CASE
30 # error BOOST_METAPARSE_NTH_OF_CASE already defined
32 #define BOOST_METAPARSE_NTH_OF_CASE(z, n, unused) \
34 int K BOOST_PP_COMMA_IF(n) \
35 BOOST_PP_ENUM_PARAMS(n, class P) \
37 struct BOOST_PP_CAT(nth_of_c, n) : \
39 boost::mpl::bool_<(0 <= K && K < n)>, \
42 boost::mpl::list<BOOST_PP_ENUM_PARAMS(n, P)> \
44 fail<error::index_out_of_range<0, n - 1, K> > \
49 BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE,
50 BOOST_METAPARSE_NTH_OF_CASE,
54 #undef BOOST_METAPARSE_NTH_OF_CASE