mirror of
https://github.com/boostorg/preprocessor.git
synced 2025-07-20 16:02:05 +02:00
Automatic recursion
[SVN r14100]
This commit is contained in:
@ -48,3 +48,17 @@ TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D,3,TEST_LIST)) == 4
|
||||
#define F(R,X) +BOOST_PP_TUPLE_ELEM(2,0,X)+2-BOOST_PP_TUPLE_ELEM(2,1,X)
|
||||
TEST_B BOOST_PP_LIST_FOR_EACH_PRODUCT(F,2,(BOOST_PP_TUPLE_TO_LIST(2,(1,0)),BOOST_PP_TUPLE_TO_LIST(2,(2,3)))) == 0 TEST_E
|
||||
#undef F
|
||||
|
||||
TEST_B BOOST_PP_LIST_CAT
|
||||
( BOOST_PP_LIST_FOLD_RIGHT
|
||||
( BOOST_PP_LIST_APPEND_D
|
||||
, BOOST_PP_TUPLE_TO_LIST
|
||||
( 3
|
||||
, ( BOOST_PP_TUPLE_TO_LIST(2,(0,x))
|
||||
, BOOST_PP_TUPLE_TO_LIST(4,(A,1,B,2))
|
||||
, BOOST_PP_TUPLE_TO_LIST(3,(C,3,D))
|
||||
)
|
||||
)
|
||||
, BOOST_PP_LIST_NIL
|
||||
)
|
||||
) == 0xA1B2C3D TEST_E
|
||||
|
@ -13,13 +13,14 @@
|
||||
#include <boost/preprocessor/enum_params.hpp>
|
||||
#include <boost/preprocessor/enum_shifted_params.hpp>
|
||||
#include <boost/preprocessor/inc.hpp>
|
||||
#include <boost/preprocessor/repeat_2nd.hpp>
|
||||
#include <boost/preprocessor/repeat_from_to.hpp>
|
||||
#include <libs/preprocessor/test/test.hpp>
|
||||
|
||||
/* *** */
|
||||
|
||||
/* RATIONALE:
|
||||
* - BOOST_PP_REPEAT, BOOST_PP_REPEAT_2ND, ... must work
|
||||
* together.
|
||||
* - BOOST_PP_REPEAT, BOOST_PP_ENUM, BOOST_PP_REPEAT_FROM_TO and must work
|
||||
* recursively together.
|
||||
* - BOOST_PP_REPEAT is already tested with
|
||||
* BOOST_PP_ENUM_PARAMS.
|
||||
* - The tested repeat count should exceed imaginable usage.
|
||||
@ -44,6 +45,18 @@ typedef char yes_type;
|
||||
yes_type is_function_helper(\
|
||||
P0 (*)(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_INC(I),P)));
|
||||
|
||||
BOOST_PP_REPEAT_2ND(BOOST_PP_INC(IS_FUNCTION_HELPER_TEST_MAX),IS_FUNCTION_HELPER,A)
|
||||
BOOST_PP_REPEAT(BOOST_PP_INC(IS_FUNCTION_HELPER_TEST_MAX),IS_FUNCTION_HELPER,A)
|
||||
|
||||
#undef IS_FUNCTION_HELPER
|
||||
|
||||
/* *** */
|
||||
|
||||
#define ELEM(_,X) X
|
||||
#define COL(I,_) +(BOOST_PP_ENUM(2,ELEM,-I))
|
||||
#define ROW(I,_) BOOST_PP_REPEAT(I,COL,_)
|
||||
|
||||
TEST_B 0 == (+1 +1+2 +1+2+3) + BOOST_PP_REPEAT_FROM_TO(2,5,ROW,_) TEST_E
|
||||
|
||||
#undef ROW
|
||||
#undef COL
|
||||
#undef ELEM
|
||||
|
Reference in New Issue
Block a user