forked from boostorg/preprocessor
Fixes for BOOST_PP_SEQ_REMOVE when the seq is its maximum size and has its last element removed. Also updated seq tests.
This commit is contained in:
@ -16,10 +16,9 @@
|
||||
# include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
# include <boost/preprocessor/logical/bool.hpp>
|
||||
# include <boost/preprocessor/logical/compl.hpp>
|
||||
# include <boost/preprocessor/seq/size.hpp>
|
||||
#
|
||||
/* A empty is one that is just BOOST_PP_SEQ_NIL,
|
||||
but for out purposes here it is a seq which
|
||||
does not start with a unary, ie '(anything)' */
|
||||
/* An empty seq is one that is just BOOST_PP_SEQ_NIL */
|
||||
#
|
||||
# define BOOST_PP_SEQ_DETAIL_IS_EMPTY(seq) \
|
||||
BOOST_PP_COMPL \
|
||||
@ -28,8 +27,23 @@
|
||||
) \
|
||||
/**/
|
||||
#
|
||||
# define BOOST_PP_SEQ_DETAIL_IS_EMPTY_SIZE(size) \
|
||||
BOOST_PP_COMPL \
|
||||
( \
|
||||
BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY_SIZE(size) \
|
||||
) \
|
||||
/**/
|
||||
#
|
||||
# define BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY(seq) \
|
||||
BOOST_PP_BOOL(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq (nil)))) \
|
||||
BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY_SIZE(BOOST_PP_SEQ_DETAIL_EMPTY_SIZE(seq)) \
|
||||
/**/
|
||||
#
|
||||
# define BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY_SIZE(size) \
|
||||
BOOST_PP_BOOL(size) \
|
||||
/**/
|
||||
#
|
||||
# define BOOST_PP_SEQ_DETAIL_EMPTY_SIZE(seq) \
|
||||
BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq (nil))) \
|
||||
/**/
|
||||
#
|
||||
# endif
|
||||
|
@ -14,17 +14,32 @@
|
||||
#
|
||||
# include <boost/preprocessor/arithmetic/inc.hpp>
|
||||
# include <boost/preprocessor/config/config.hpp>
|
||||
# include <boost/preprocessor/control/expr_iif.hpp>
|
||||
# include <boost/preprocessor/facilities/identity.hpp>
|
||||
# include <boost/preprocessor/logical/bitand.hpp>
|
||||
# include <boost/preprocessor/seq/detail/is_empty.hpp>
|
||||
# include <boost/preprocessor/seq/detail/split.hpp>
|
||||
# include <boost/preprocessor/tuple/elem.hpp>
|
||||
#
|
||||
# /* BOOST_PP_SEQ_REST_N */
|
||||
#
|
||||
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
|
||||
# define BOOST_PP_SEQ_REST_N(n, seq) BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_SEQ_SPLIT(BOOST_PP_INC(n), BOOST_PP_IDENTITY( (nil) seq )))()
|
||||
# define BOOST_PP_SEQ_REST_N(n, seq) BOOST_PP_SEQ_REST_N_DETAIL_EXEC(n, seq, BOOST_PP_SEQ_DETAIL_EMPTY_SIZE(seq))
|
||||
# else
|
||||
# define BOOST_PP_SEQ_REST_N(n, seq) BOOST_PP_SEQ_REST_N_I(n, seq)
|
||||
# define BOOST_PP_SEQ_REST_N_I(n, seq) BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_SEQ_SPLIT(BOOST_PP_INC(n), BOOST_PP_IDENTITY( (nil) seq )))()
|
||||
# define BOOST_PP_SEQ_REST_N_I(n, seq) BOOST_PP_SEQ_REST_N_DETAIL_EXEC(n, seq, BOOST_PP_SEQ_DETAIL_EMPTY_SIZE(seq))
|
||||
# endif
|
||||
#
|
||||
# define BOOST_PP_SEQ_REST_N_DETAIL_EXEC(n, seq, size) \
|
||||
BOOST_PP_EXPR_IIF \
|
||||
( \
|
||||
BOOST_PP_BITAND \
|
||||
( \
|
||||
BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY_SIZE(size), \
|
||||
BOOST_PP_NOT_EQUAL(n,size) \
|
||||
), \
|
||||
BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_SEQ_SPLIT(BOOST_PP_INC(n), BOOST_PP_IDENTITY( (nil) seq )))() \
|
||||
) \
|
||||
/**/
|
||||
#
|
||||
# endif
|
||||
|
64
test/seq.cxx
64
test/seq.cxx
@ -31,6 +31,63 @@
|
||||
|
||||
# define SEQ_NONE ()
|
||||
# define SEQ (4)(1)(5)(2)
|
||||
|
||||
# define SEQ_239 \
|
||||
(1)(2)(3)(4)(5)(6)(7)(8)(9) \
|
||||
(10)(11)(12)(13)(14)(15)(16)(17)(18)(19) \
|
||||
(20)(21)(22)(23)(24)(25)(26)(27)(28)(29) \
|
||||
(30)(31)(32)(33)(34)(35)(36)(37)(38)(39) \
|
||||
(40)(41)(42)(43)(44)(45)(46)(47)(48)(49) \
|
||||
(50)(51)(52)(53)(54)(55)(56)(57)(58)(59) \
|
||||
(60)(61)(62)(63)(64)(65)(66)(67)(68)(69) \
|
||||
(70)(71)(72)(73)(74)(75)(76)(77)(78)(79) \
|
||||
(80)(81)(82)(83)(84)(85)(86)(87)(88)(89) \
|
||||
(90)(91)(92)(93)(94)(95)(96)(97)(98)(99) \
|
||||
(100)(101)(102)(103)(104)(105)(106)(107)(108)(109) \
|
||||
(110)(111)(112)(113)(114)(115)(116)(117)(118)(119) \
|
||||
(120)(121)(122)(123)(124)(125)(126)(127)(128)(129) \
|
||||
(130)(131)(132)(133)(134)(135)(136)(137)(138)(139) \
|
||||
(140)(141)(142)(143)(144)(145)(146)(147)(148)(149) \
|
||||
(150)(151)(152)(153)(154)(155)(156)(157)(158)(159) \
|
||||
(160)(161)(162)(163)(164)(165)(166)(167)(168)(169) \
|
||||
(170)(171)(172)(173)(174)(175)(176)(177)(178)(179) \
|
||||
(180)(181)(182)(183)(184)(185)(186)(187)(188)(189) \
|
||||
(190)(191)(192)(193)(194)(195)(196)(197)(198)(199) \
|
||||
(200)(201)(202)(203)(204)(205)(206)(207)(208)(209) \
|
||||
(210)(211)(212)(213)(214)(215)(216)(217)(218)(219) \
|
||||
(220)(221)(222)(223)(224)(225)(226)(227)(228)(229) \
|
||||
(230)(231)(232)(233)(234)(235)(236)(237)(238)(239)
|
||||
|
||||
# define SEQ_255 \
|
||||
(1)(2)(3)(4)(5)(6)(7)(8)(9) \
|
||||
(10)(11)(12)(13)(14)(15)(16)(17)(18)(19) \
|
||||
(20)(21)(22)(23)(24)(25)(26)(27)(28)(29) \
|
||||
(30)(31)(32)(33)(34)(35)(36)(37)(38)(39) \
|
||||
(40)(41)(42)(43)(44)(45)(46)(47)(48)(49) \
|
||||
(50)(51)(52)(53)(54)(55)(56)(57)(58)(59) \
|
||||
(60)(61)(62)(63)(64)(65)(66)(67)(68)(69) \
|
||||
(70)(71)(72)(73)(74)(75)(76)(77)(78)(79) \
|
||||
(80)(81)(82)(83)(84)(85)(86)(87)(88)(89) \
|
||||
(90)(91)(92)(93)(94)(95)(96)(97)(98)(99) \
|
||||
(100)(101)(102)(103)(104)(105)(106)(107)(108)(109) \
|
||||
(110)(111)(112)(113)(114)(115)(116)(117)(118)(119) \
|
||||
(120)(121)(122)(123)(124)(125)(126)(127)(128)(129) \
|
||||
(130)(131)(132)(133)(134)(135)(136)(137)(138)(139) \
|
||||
(140)(141)(142)(143)(144)(145)(146)(147)(148)(149) \
|
||||
(150)(151)(152)(153)(154)(155)(156)(157)(158)(159) \
|
||||
(160)(161)(162)(163)(164)(165)(166)(167)(168)(169) \
|
||||
(170)(171)(172)(173)(174)(175)(176)(177)(178)(179) \
|
||||
(180)(181)(182)(183)(184)(185)(186)(187)(188)(189) \
|
||||
(190)(191)(192)(193)(194)(195)(196)(197)(198)(199) \
|
||||
(200)(201)(202)(203)(204)(205)(206)(207)(208)(209) \
|
||||
(210)(211)(212)(213)(214)(215)(216)(217)(218)(219) \
|
||||
(220)(221)(222)(223)(224)(225)(226)(227)(228)(229) \
|
||||
(230)(231)(232)(233)(234)(235)(236)(237)(238)(239) \
|
||||
(240)(241)(242)(243)(244)(245)(246)(247)(248)(249) \
|
||||
(250)(251)(252)(253)(254)(255)
|
||||
|
||||
# define SEQ_256 SEQ_255(256)
|
||||
|
||||
# define SEQVAR (4,5,8,3,61)(1,0)(5,22,43)(2)(17,45,33)
|
||||
|
||||
# define REVERSAL(s, x, y) BOOST_PP_SUB(y, x)
|
||||
@ -40,6 +97,9 @@
|
||||
|
||||
BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_SEQ_HEAD(SEQ_NONE)) == 1 END
|
||||
BEGIN BOOST_PP_SEQ_HEAD(SEQ) == 4 END
|
||||
BEGIN BOOST_PP_SEQ_HEAD(SEQ_239) == 1 END
|
||||
BEGIN BOOST_PP_SEQ_HEAD(SEQ_255) == 1 END
|
||||
BEGIN BOOST_PP_SEQ_HEAD(SEQ_256) == 1 END
|
||||
|
||||
BEGIN BOOST_PP_SEQ_FOLD_LEFT(CAT_S, 1, SEQ_NONE) == 11 END
|
||||
BEGIN BOOST_PP_SEQ_FOLD_LEFT(SUB_S, 22, SEQ) == 10 END
|
||||
@ -102,6 +162,10 @@ BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REMOVE(SEQ, 0)) == 152 END
|
||||
BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REMOVE(SEQ, 2)) == 412 END
|
||||
BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REMOVE(SEQ, 3)) == 415 END
|
||||
|
||||
BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_REMOVE(SEQ_239, 238)) == 238 END
|
||||
BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_REMOVE(SEQ_255, 254)) == 254 END
|
||||
BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_REMOVE(SEQ_256, 255)) == 255 END
|
||||
|
||||
BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REPLACE(SEQ_NONE, 0, 22)) == 22 END
|
||||
BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REPLACE(SEQ, 0, 3)) == 3152 END
|
||||
BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_REPLACE(SEQ, 1, 3)) == 4352 END
|
||||
|
Reference in New Issue
Block a user