#include "boost/preprocessor/arithmetic/add.hpp" #include "boost/preprocessor/arithmetic/sub.hpp" #include "boost/preprocessor/comma_if.hpp" #include "boost/preprocessor/repeat.hpp" #include "boost/preprocessor/tuple/elem.hpp" #include "boost/preprocessor/cat.hpp" // BOOST_MPL_PP_RECURSE_NUMBER( pre, nested, T, i, j, post ) // if i = 0, i = 2 then // pre pre nested , T##0 post , T##1 post #define BOOST_MPL_PP_RECURSE_NUMBER_AUX1( i, op ) \ BOOST_PP_TUPLE_ELEM(1, 0, op) \ /**/ #define BOOST_MPL_PP_RECURSE_NUMBER_AUX2( i, op ) \ , \ BOOST_PP_CAT( \ BOOST_PP_TUPLE_ELEM(3, 1, op) \ , BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 0, op), i) \ ) \ BOOST_PP_TUPLE_ELEM(3, 2, op) \ /**/ #define BOOST_MPL_PP_RECURSE_NUMBER(pre, nested, T, i, j, post) \ BOOST_PP_REPEAT( \ BOOST_PP_SUB(j, i) \ , BOOST_MPL_PP_RECURSE_NUMBER_AUX1 \ , (pre) \ ) \ nested \ BOOST_PP_REPEAT( \ BOOST_PP_SUB(j, i) \ , BOOST_MPL_PP_RECURSE_NUMBER_AUX2 \ , (i, T, post) \ ) \ /**/ // BOOST_MPL_PP_NUMBER_RECURSE( pre, T, i, j, nested, post ) // if i = 0, i = 2 then // pre T##0 , pre T##1 , nested post post #define BOOST_MPL_PP_NUMBER_RECURSE_AUX1( i, op ) \ BOOST_PP_TUPLE_ELEM(3, 1, op) \ BOOST_PP_CAT( \ BOOST_PP_TUPLE_ELEM(3, 2, op) \ , BOOST_PP_ADD(BOOST_PP_TUPLE_ELEM(3, 0, op), i) \ ) \ , \ /**/ #define BOOST_MPL_PP_NUMBER_RECURSE_AUX2( i, op ) \ BOOST_PP_TUPLE_ELEM(1, 0, op) \ /**/ #define BOOST_MPL_PP_NUMBER_RECURSE(pre, T, i, j, nested, post) \ BOOST_PP_REPEAT( \ BOOST_PP_SUB(j, i) \ , BOOST_MPL_PP_NUMBER_RECURSE_AUX1 \ , (i, pre, T) \ ) \ nested \ BOOST_PP_REPEAT( \ BOOST_PP_SUB(j, i) \ , BOOST_MPL_PP_NUMBER_RECURSE_AUX2 \ , (post) \ ) \ /**/