#include <boost/preprocessor/arithmetic/dec.hpp> #include <boost/preprocessor/arithmetic/inc.hpp> #include <boost/preprocessor/comparison/not_equal.hpp> #include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/repetition/for.hpp> #include <boost/preprocessor/tuple/elem.hpp> #define PRED(r, state) \ BOOST_PP_NOT_EQUAL( \ BOOST_PP_TUPLE_ELEM(4, 0, state), \ BOOST_PP_INC( \ BOOST_PP_TUPLE_ELEM(4, 1, state) \ ) \ ) \ /**/ #define OP(r, state) \ ( \ BOOST_PP_INC( \ BOOST_PP_TUPLE_ELEM(4, 0, state) \ ), \ BOOST_PP_TUPLE_ELEM(4, 1, state), \ BOOST_PP_TUPLE_ELEM(4, 2, state), \ BOOST_PP_INC( \ BOOST_PP_TUPLE_ELEM(4, 3, state) \ ) \ ) \ /**/ #define MACRO(r, state) \ BOOST_PP_COMMA_IF( \ BOOST_PP_TUPLE_ELEM(4, 3, state) \ ) template< \ BOOST_PP_FOR_ ## r( \ (0, BOOST_PP_TUPLE_ELEM(4, 0, state), _, 0), \ PRED_2, OP, MACRO_2 \ ) \ > class BOOST_PP_CAT( \ BOOST_PP_TUPLE_ELEM(4, 2, state), \ BOOST_PP_TUPLE_ELEM(4, 0, state) \ ) \ /**/ #define PRED_2(r, state) \ BOOST_PP_NOT_EQUAL( \ BOOST_PP_TUPLE_ELEM(4, 0, state), \ BOOST_PP_TUPLE_ELEM(4, 1, state) \ ) \ /**/ #define MACRO_2(r, state) \ BOOST_PP_COMMA_IF( \ BOOST_PP_TUPLE_ELEM(4, 0, state) \ ) class \ /**/ #define TEMPLATE_TEMPLATE(low, high, name) \ BOOST_PP_FOR( \ (low, high, name, 0), \ PRED, OP, MACRO \ ) \ /**/ TEMPLATE_TEMPLATE(2, 4, T) /* expands to... template<class, class> class T2, template<class, class, class> class T3, template<class, class, class, class> class T4 */
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)