1 #ifndef BOOST_METAPARSE_V1_SEQUENCE_APPLY_HPP 2 #define BOOST_METAPARSE_V1_SEQUENCE_APPLY_HPP 3 4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2015. 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/letter.hpp> 10 #include <boost/metaparse/v1/sequence.hpp> 11 12 #include <boost/metaparse/limit_sequence_size.hpp> 13 14 #include <boost/mpl/at.hpp> 15 16 #include <boost/preprocessor/cat.hpp> 17 #include <boost/preprocessor/repetition/repeat_from_to.hpp> 18 #include <boost/preprocessor/repetition/enum.hpp> 19 #include <boost/preprocessor/repetition/enum_params.hpp> 20 #include <boost/preprocessor/tuple/eat.hpp> 21 22 namespace boost 23 { 24 namespace metaparse 25 { 26 namespace v1 27 { 28 #ifdef BOOST_METAPARSE_SEQUENCE_APPLY_ARG 29 # error BOOST_METAPARSE_SEQUENCE_APPLY_ARG already defined 30 #endif 31 #define BOOST_METAPARSE_SEQUENCE_APPLY_ARG(z, n, container) \ 32 typename boost::mpl::at_c<container, n>::type 33 34 #ifdef BOOST_METAPARSE_SEQUENCE_APPLY 35 # error BOOST_METAPARSE_SEQUENCE_APPLY already defined 36 #endif 37 #define BOOST_METAPARSE_SEQUENCE_APPLY(z, n, unused) \ 38 namespace impl \ 39 { \ 40 template < \ 41 template <BOOST_PP_ENUM(n, class BOOST_PP_TUPLE_EAT(3), ~)> class T \ 42 > \ 43 struct BOOST_PP_CAT(sequence_apply_transform, n) \ 44 { \ 45 typedef BOOST_PP_CAT(sequence_apply_transform, n) type; \ 46 \ 47 template <class V> \ 48 struct apply \ 49 { \ 50 typedef T<BOOST_PP_ENUM(n, BOOST_METAPARSE_SEQUENCE_APPLY_ARG, V)> type; \ 51 }; \ 52 }; \ 53 } \ 54 \ 55 template < \ 56 template <BOOST_PP_ENUM(n, class BOOST_PP_TUPLE_EAT(3), ~)> class T, \ 57 BOOST_PP_ENUM_PARAMS(n, class P) \ 58 > \ 59 struct BOOST_PP_CAT(sequence_apply, n) : \ 60 transform< \ 61 sequence<BOOST_PP_ENUM_PARAMS(n, P)>, \ 62 BOOST_PP_CAT(impl::sequence_apply_transform, n)<T> \ 63 > \ 64 {}; 65 66 BOOST_PP_REPEAT_FROM_TO( 67 1, 68 BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, 69 BOOST_METAPARSE_SEQUENCE_APPLY, 70 ~ 71 ) 72 73 #undef BOOST_METAPARSE_SEQUENCE_APPLY 74 #undef BOOST_METAPARSE_SEQUENCE_APPLY_ARG 75 } 76 } 77 } 78 79 #endif 80 81