From 735e301c46769a90392cb6cf2d9fb469b71408f3 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 12 Sep 2015 19:53:59 -0400 Subject: [PATCH] Added BOOST_PP_IDENTITY_N functionality with test. --- include/boost/preprocessor/facilities/identity.hpp | 4 ++++ include/boost/preprocessor/tuple/eat.hpp | 11 ++++++++++- test/facilities.cxx | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/boost/preprocessor/facilities/identity.hpp b/include/boost/preprocessor/facilities/identity.hpp index 13ec4ca..8a7834d 100644 --- a/include/boost/preprocessor/facilities/identity.hpp +++ b/include/boost/preprocessor/facilities/identity.hpp @@ -8,6 +8,7 @@ # */ # # /* Revised by Paul Mensonides (2002) */ +# /* Revised by Edward Diener (2015) */ # # /* See http://www.boost.org for most recent version. */ # @@ -15,9 +16,12 @@ # define BOOST_PREPROCESSOR_FACILITIES_IDENTITY_HPP # # include +# include # # /* BOOST_PP_IDENTITY */ # # define BOOST_PP_IDENTITY(item) item BOOST_PP_EMPTY # +# define BOOST_PP_IDENTITY_N(item,n) item BOOST_PP_TUPLE_EAT_N(n) +# # endif diff --git a/include/boost/preprocessor/tuple/eat.hpp b/include/boost/preprocessor/tuple/eat.hpp index 708015e..7e8a100 100644 --- a/include/boost/preprocessor/tuple/eat.hpp +++ b/include/boost/preprocessor/tuple/eat.hpp @@ -8,7 +8,7 @@ # */ # # /* Revised by Paul Mensonides (2002-2011) */ -# /* Revised by Edward Diener (2011) */ +# /* Revised by Edward Diener (2011,2015) */ # # /* See http://www.boost.org for most recent version. */ # @@ -38,6 +38,15 @@ # endif # define BOOST_PP_TUPLE_EAT_I(size) BOOST_PP_TUPLE_EAT_ ## size # endif +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() +# define BOOST_PP_TUPLE_EAT_N(size) BOOST_PP_TUPLE_EAT_N_I(size) +# else +# define BOOST_PP_TUPLE_EAT_N(size) BOOST_PP_TUPLE_EAT_N_OO((size)) +# define BOOST_PP_TUPLE_EAT_N_OO(par) BOOST_PP_TUPLE_EAT_N_I ## par +# endif +# define BOOST_PP_TUPLE_EAT_N_I(size) BOOST_PP_TUPLE_EAT_ ## size +# # define BOOST_PP_TUPLE_EAT_1(e0) # define BOOST_PP_TUPLE_EAT_2(e0, e1) # define BOOST_PP_TUPLE_EAT_3(e0, e1, e2) diff --git a/test/facilities.cxx b/test/facilities.cxx index f81b6a0..772c2cf 100644 --- a/test/facilities.cxx +++ b/test/facilities.cxx @@ -26,6 +26,7 @@ BEGIN BOOST_PP_APPLY((BOOST_PP_EMPTY))() 0 == 0 END BEGIN BOOST_PP_EXPAND(MACRO ARGS) == 1 END BEGIN BOOST_PP_IDENTITY(1)() == 1 END +BEGIN BOOST_PP_IDENTITY_N(36,10)(0,1,2,3,4,5,6,7,8,9) == 36 END BEGIN BOOST_PP_CAT(BOOST_PP_INTERCEPT, 2) 1 == 1 END