From 0a23b4d6a6ce54bebc2f5b210aadcc473f59161d Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sun, 27 Apr 2014 12:00:13 -0400 Subject: [PATCH 01/19] Fixes for empty tuple processing --- .../preprocessor/array/detail/get_data.hpp | 52 +++++++++++++++++++ .../boost/preprocessor/array/push_back.hpp | 4 +- .../boost/preprocessor/array/push_front.hpp | 4 +- include/boost/preprocessor/list/to_array.hpp | 6 ++- include/boost/preprocessor/tuple/elem.hpp | 27 +++++++++- 5 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 include/boost/preprocessor/array/detail/get_data.hpp diff --git a/include/boost/preprocessor/array/detail/get_data.hpp b/include/boost/preprocessor/array/detail/get_data.hpp new file mode 100644 index 0000000..d72547a --- /dev/null +++ b/include/boost/preprocessor/array/detail/get_data.hpp @@ -0,0 +1,52 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. * +# * Distributed under the Boost Software License, Version 1.0. (See * +# * accompanying file LICENSE_1_0.txt or copy at * +# * http://www.boost.org/LICENSE_1_0.txt) * +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP +# define BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP +# +# include +# include +# +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER != 1400 +# include +# include +# include +# include +# +# /* BOOST_PP_ARRAY_DETAIL_GET_DATA */ +# +# define BOOST_PP_ARRAY_DETAIL_GET_DATA_REM(...) BOOST_PP_CAT(__VA_ARGS__,) +# define BOOST_PP_ARRAY_DETAIL_GET_DATA_TUPLE_REM(size) BOOST_PP_ARRAY_DETAIL_GET_DATA_REM +# define BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE(size, data) BOOST_PP_ARRAY_DETAIL_GET_DATA_TUPLE_REM(size) data +# define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY(size, data) BOOST_PP_TUPLE_REM(size) data +# define BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO(size, data) \ + BOOST_PP_IF \ + ( \ + size, \ + BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY, \ + BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE \ + ) \ + (size,data) \ +/**/ +# define BOOST_PP_ARRAY_DETAIL_GET_DATA(size, data) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_IS_1(size), \ + BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE, \ + BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO \ + ) \ + (size,data) \ +/**/ +# else +# define BOOST_PP_ARRAY_DETAIL_GET_DATA(size, data) BOOST_PP_TUPLE_REM(size) data +# endif /* BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER != 1400 */ +# +# endif /* BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP */ diff --git a/include/boost/preprocessor/array/push_back.hpp b/include/boost/preprocessor/array/push_back.hpp index 6d98d8e..5dce9e0 100644 --- a/include/boost/preprocessor/array/push_back.hpp +++ b/include/boost/preprocessor/array/push_back.hpp @@ -1,6 +1,7 @@ # /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2002. +# * (C) Copyright Edward Diener 2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) @@ -18,6 +19,7 @@ # include # include # include +# include # # /* BOOST_PP_ARRAY_PUSH_BACK */ # @@ -28,6 +30,6 @@ # define BOOST_PP_ARRAY_PUSH_BACK_D(array, elem) BOOST_PP_ARRAY_PUSH_BACK_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem) # endif # -# define BOOST_PP_ARRAY_PUSH_BACK_I(size, data, elem) (BOOST_PP_INC(size), (BOOST_PP_TUPLE_REM(size) data BOOST_PP_COMMA_IF(size) elem)) +# define BOOST_PP_ARRAY_PUSH_BACK_I(size, data, elem) (BOOST_PP_INC(size), (BOOST_PP_ARRAY_DETAIL_GET_DATA(size,data) BOOST_PP_COMMA_IF(size) elem)) # # endif diff --git a/include/boost/preprocessor/array/push_front.hpp b/include/boost/preprocessor/array/push_front.hpp index 59344c3..a6c6dc7 100644 --- a/include/boost/preprocessor/array/push_front.hpp +++ b/include/boost/preprocessor/array/push_front.hpp @@ -1,6 +1,7 @@ # /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2002. +# * (C) Copyright Edward Diener 2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) @@ -18,6 +19,7 @@ # include # include # include +# include # # /* BOOST_PP_ARRAY_PUSH_FRONT */ # @@ -28,6 +30,6 @@ # define BOOST_PP_ARRAY_PUSH_FRONT_D(array, elem) BOOST_PP_ARRAY_PUSH_FRONT_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem) # endif # -# define BOOST_PP_ARRAY_PUSH_FRONT_I(size, data, elem) (BOOST_PP_INC(size), (elem BOOST_PP_COMMA_IF(size) BOOST_PP_TUPLE_REM(size) data)) +# define BOOST_PP_ARRAY_PUSH_FRONT_I(size, data, elem) (BOOST_PP_INC(size), (elem BOOST_PP_COMMA_IF(size) BOOST_PP_ARRAY_DETAIL_GET_DATA(size,data))) # # endif diff --git a/include/boost/preprocessor/list/to_array.hpp b/include/boost/preprocessor/list/to_array.hpp index 83f8a63..5a0433d 100644 --- a/include/boost/preprocessor/list/to_array.hpp +++ b/include/boost/preprocessor/list/to_array.hpp @@ -1,6 +1,7 @@ # /* ************************************************************************** # * * -# * (C) Copyright Edward Diener 2011. +# * (C) Copyright Paul Mensonides 2011. +# * (C) Copyright Edward Diener 2011,2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) @@ -19,6 +20,7 @@ # include # include # include +# include # # /* BOOST_PP_LIST_TO_ARRAY */ # @@ -114,7 +116,7 @@ # endif # define BOOST_PP_LIST_TO_ARRAY_P(d, state) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(3, 0, state)) # define BOOST_PP_LIST_TO_ARRAY_O(d, state) BOOST_PP_LIST_TO_ARRAY_O_I state -# define BOOST_PP_LIST_TO_ARRAY_O_I(list, size, tuple) (BOOST_PP_LIST_REST(list), BOOST_PP_INC(size), (BOOST_PP_TUPLE_REM(size) tuple, BOOST_PP_LIST_FIRST(list))) +# define BOOST_PP_LIST_TO_ARRAY_O_I(list, size, tuple) (BOOST_PP_LIST_REST(list), BOOST_PP_INC(size), (BOOST_PP_ARRAY_DETAIL_GET_DATA(size,tuple), BOOST_PP_LIST_FIRST(list))) # # /* BOOST_PP_LIST_TO_ARRAY_D */ # diff --git a/include/boost/preprocessor/tuple/elem.hpp b/include/boost/preprocessor/tuple/elem.hpp index 3eba1c5..762a171 100644 --- a/include/boost/preprocessor/tuple/elem.hpp +++ b/include/boost/preprocessor/tuple/elem.hpp @@ -8,7 +8,7 @@ # */ # # /* Revised by Paul Mensonides (2002-2011) */ -# /* Revised by Edward Diener (2011) */ +# /* Revised by Edward Diener (2011,2014) */ # # /* See http://www.boost.org for most recent version. */ # @@ -21,15 +21,38 @@ # include # include # +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC +# include +# include +# include +# endif +# # if BOOST_PP_VARIADICS # if BOOST_PP_VARIADICS_MSVC # define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__), (__VA_ARGS__)) # define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args) # define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,) +/* + Use BOOST_PP_TUPLE_ELEM_O_2_CAT if it is a single element tuple ( which might be empty ) + else use BOOST_PP_REM. This fixes a VC++ problem with an empty tuple and BOOST_PP_TUPLE_ELEM + functionality. +*/ +# define BOOST_PP_TUPLE_ELEM_O_2_CAT(...) BOOST_PP_CAT(__VA_ARGS__,) +# define BOOST_PP_TUPLE_ELEM_O_2_SINGLE(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_TUPLE_ELEM_O_2_CAT tuple) +# define BOOST_PP_TUPLE_ELEM_O_2_ANY(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple) +# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \ + BOOST_PP_TUPLE_ELEM_O_2_SINGLE, \ + BOOST_PP_TUPLE_ELEM_O_2_ANY \ + ) \ + (n, tuple) \ + /**/ # else # define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__) +# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple) # endif -# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple) # define BOOST_PP_TUPLE_ELEM_O_3(size, n, tuple) BOOST_PP_TUPLE_ELEM_O_2(n, tuple) # else # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() From d2bfda8308cb568372fb41b49b5393b6b9b904ea Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 28 Apr 2014 19:24:42 -0400 Subject: [PATCH 02/19] Added variadic is_empty and is_begin_parens along with tests. --- .../facilities/detail/is_empty.hpp | 55 ++++++++++++++++++ .../preprocessor/facilities/is_empty.hpp | 13 ++++- .../facilities/is_empty_variadic.hpp | 56 +++++++++++++++++++ include/boost/preprocessor/punctuation.hpp | 1 + .../punctuation/detail/is_begin_parens.hpp | 48 ++++++++++++++++ .../punctuation/is_begin_parens.hpp | 51 +++++++++++++++++ test/Jamfile.v2 | 16 ++++++ test/isempty.c | 12 ++++ test/isempty.cpp | 12 ++++ test/isempty.cxx | 42 ++++++++++++++ test/punctuation.c | 14 +++++ test/punctuation.cpp | 14 +++++ test/punctuation.cxx | 42 ++++++++++++++ 13 files changed, 375 insertions(+), 1 deletion(-) create mode 100644 include/boost/preprocessor/facilities/detail/is_empty.hpp create mode 100644 include/boost/preprocessor/facilities/is_empty_variadic.hpp create mode 100644 include/boost/preprocessor/punctuation/detail/is_begin_parens.hpp create mode 100644 include/boost/preprocessor/punctuation/is_begin_parens.hpp create mode 100644 test/isempty.c create mode 100644 test/isempty.cpp create mode 100644 test/isempty.cxx create mode 100644 test/punctuation.c create mode 100644 test/punctuation.cpp create mode 100644 test/punctuation.cxx diff --git a/include/boost/preprocessor/facilities/detail/is_empty.hpp b/include/boost/preprocessor/facilities/detail/is_empty.hpp new file mode 100644 index 0000000..e044970 --- /dev/null +++ b/include/boost/preprocessor/facilities/detail/is_empty.hpp @@ -0,0 +1,55 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +#ifndef BOOST_PREPROCESSOR_DETAIL_IS_EMPTY_HPP +#define BOOST_PREPROCESSOR_DETAIL_IS_EMPTY_HPP + +#include + +#if BOOST_PP_VARIADICS_MSVC + +# pragma warning(once:4002) + +#define BOOST_PP_DETAIL_IS_EMPTY_IIF_0(t, b) b +#define BOOST_PP_DETAIL_IS_EMPTY_IIF_1(t, b) t + +#else + +#define BOOST_PP_DETAIL_IS_EMPTY_IIF_0(t, ...) __VA_ARGS__ +#define BOOST_PP_DETAIL_IS_EMPTY_IIF_1(t, ...) t + +#endif + +#if BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 + +#define BOOST_PP_DETAIL_IS_EMPTY_PROCESS(param) \ + BOOST_PP_IS_BEGIN_PARENS \ + ( \ + BOOST_PP_DETAIL_IS_EMPTY_NON_FUNCTION_C param () \ + ) \ +/**/ + +#else + +#define BOOST_PP_DETAIL_IS_EMPTY_PROCESS(...) \ + BOOST_PP_IS_BEGIN_PARENS \ + ( \ + BOOST_PP_DETAIL_IS_EMPTY_NON_FUNCTION_C __VA_ARGS__ () \ + ) \ +/**/ + +#endif + +#define BOOST_PP_DETAIL_IS_EMPTY_PRIMITIVE_CAT(a, b) a ## b +#define BOOST_PP_DETAIL_IS_EMPTY_IIF(bit) BOOST_PP_DETAIL_IS_EMPTY_PRIMITIVE_CAT(BOOST_PP_DETAIL_IS_EMPTY_IIF_,bit) +#define BOOST_PP_DETAIL_IS_EMPTY_NON_FUNCTION_C(...) () + +#endif /* BOOST_PREPROCESSOR_DETAIL_IS_EMPTY_HPP */ diff --git a/include/boost/preprocessor/facilities/is_empty.hpp b/include/boost/preprocessor/facilities/is_empty.hpp index 638265c..b1094d8 100644 --- a/include/boost/preprocessor/facilities/is_empty.hpp +++ b/include/boost/preprocessor/facilities/is_empty.hpp @@ -1,6 +1,7 @@ # /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2003. +# * (C) Copyright Edward Diener 2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) @@ -13,6 +14,14 @@ # define BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP # # include +# +# if BOOST_PP_VARIADICS +# +# include +# +# else +# +# include # include # include # include @@ -40,4 +49,6 @@ # define BOOST_PP_IS_EMPTY_DEF_BOOST_PP_IS_EMPTY_HELPER 0, BOOST_PP_NIL # endif # -# endif +# endif /* BOOST_PP_VARIADICS */ +# +# endif /* BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP */ diff --git a/include/boost/preprocessor/facilities/is_empty_variadic.hpp b/include/boost/preprocessor/facilities/is_empty_variadic.hpp new file mode 100644 index 0000000..27b4ec0 --- /dev/null +++ b/include/boost/preprocessor/facilities/is_empty_variadic.hpp @@ -0,0 +1,56 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP +# define BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP +# +# include +# +# if BOOST_PP_VARIADICS +# +# include +# include +# +#define BOOST_PP_IS_EMPTY_GEN_ZERO(...) 0 +#if BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 +# +#define BOOST_PP_IS_EMPTY(param) \ + BOOST_PP_DETAIL_IS_EMPTY_IIF \ + ( \ + BOOST_PP_IS_BEGIN_PARENS \ + ( \ + param \ + ) \ + ) \ + ( \ + BOOST_PP_IS_EMPTY_GEN_ZERO, \ + BOOST_PP_DETAIL_IS_EMPTY_PROCESS \ + ) \ + (param) \ +/**/ +# else +#define BOOST_PP_IS_EMPTY(...) \ + BOOST_PP_DETAIL_IS_EMPTY_IIF \ + ( \ + BOOST_PP_IS_BEGIN_PARENS \ + ( \ + __VA_ARGS__ \ + ) \ + ) \ + ( \ + BOOST_PP_IS_EMPTY_GEN_ZERO, \ + BOOST_PP_DETAIL_IS_EMPTY_PROCESS \ + ) \ + (__VA_ARGS__) \ +/**/ +# endif /* BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 */ +# endif /* BOOST_PP_VARIADICS */ +# endif /* BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP */ diff --git a/include/boost/preprocessor/punctuation.hpp b/include/boost/preprocessor/punctuation.hpp index 72da73e..a96bbff 100644 --- a/include/boost/preprocessor/punctuation.hpp +++ b/include/boost/preprocessor/punctuation.hpp @@ -14,6 +14,7 @@ # # include # include +# include # include # include # diff --git a/include/boost/preprocessor/punctuation/detail/is_begin_parens.hpp b/include/boost/preprocessor/punctuation/detail/is_begin_parens.hpp new file mode 100644 index 0000000..c94ccf3 --- /dev/null +++ b/include/boost/preprocessor/punctuation/detail/is_begin_parens.hpp @@ -0,0 +1,48 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +#ifndef BOOST_PREPROCESSOR_DETAIL_IS_BEGIN_PARENS_HPP +#define BOOST_PREPROCESSOR_DETAIL_IS_BEGIN_PARENS_HPP + +#if BOOST_PP_VARIADICS_MSVC + +#include + +#define BOOST_PP_DETAIL_VD_IBP_CAT(a, b) BOOST_PP_DETAIL_VD_IBP_CAT_I(a, b) +#define BOOST_PP_DETAIL_VD_IBP_CAT_I(a, b) BOOST_PP_DETAIL_VD_IBP_CAT_II(a ## b) +#define BOOST_PP_DETAIL_VD_IBP_CAT_II(res) res + +#define BOOST_PP_DETAIL_IBP_SPLIT(i, ...) \ + BOOST_PP_DETAIL_VD_IBP_CAT(BOOST_PP_DETAIL_IBP_PRIMITIVE_CAT(BOOST_PP_DETAIL_IBP_SPLIT_,i)(__VA_ARGS__),BOOST_PP_EMPTY()) \ +/**/ + +#define BOOST_PP_DETAIL_IBP_IS_VARIADIC_C(...) 1 1 + +#else + +#define BOOST_PP_DETAIL_IBP_SPLIT(i, ...) \ + BOOST_PP_DETAIL_IBP_PRIMITIVE_CAT(BOOST_PP_DETAIL_IBP_SPLIT_,i)(__VA_ARGS__) \ +/**/ + +#define BOOST_PP_DETAIL_IBP_IS_VARIADIC_C(...) 1 + +#endif /* BOOST_PP_VARIADICS_MSVC */ + +#define BOOST_PP_DETAIL_IBP_SPLIT_0(a, ...) a +#define BOOST_PP_DETAIL_IBP_SPLIT_1(a, ...) __VA_ARGS__ + +#define BOOST_PP_DETAIL_IBP_CAT(a, ...) BOOST_PP_DETAIL_IBP_PRIMITIVE_CAT(a,__VA_ARGS__) +#define BOOST_PP_DETAIL_IBP_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__ + +#define BOOST_PP_DETAIL_IBP_IS_VARIADIC_R_1 1, +#define BOOST_PP_DETAIL_IBP_IS_VARIADIC_R_BOOST_PP_DETAIL_IBP_IS_VARIADIC_C 0, + +#endif /* BOOST_PREPROCESSOR_DETAIL_IS_BEGIN_PARENS_HPP */ diff --git a/include/boost/preprocessor/punctuation/is_begin_parens.hpp b/include/boost/preprocessor/punctuation/is_begin_parens.hpp new file mode 100644 index 0000000..20b32bc --- /dev/null +++ b/include/boost/preprocessor/punctuation/is_begin_parens.hpp @@ -0,0 +1,51 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_IS_BEGIN_PARENS_HPP +# define BOOST_PREPROCESSOR_IS_BEGIN_PARENS_HPP + +# include + +#if BOOST_PP_VARIADICS + +#include + +#if BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 + +#define BOOST_PP_IS_BEGIN_PARENS(param) \ + BOOST_PP_DETAIL_IBP_SPLIT \ + ( \ + 0, \ + BOOST_PP_DETAIL_IBP_CAT \ + ( \ + BOOST_PP_DETAIL_IBP_IS_VARIADIC_R_, \ + BOOST_PP_DETAIL_IBP_IS_VARIADIC_C param \ + ) \ + ) \ +/**/ + +#else + +#define BOOST_PP_IS_BEGIN_PARENS(...) \ + BOOST_PP_DETAIL_IBP_SPLIT \ + ( \ + 0, \ + BOOST_PP_DETAIL_IBP_CAT \ + ( \ + BOOST_PP_DETAIL_IBP_IS_VARIADIC_R_, \ + BOOST_PP_DETAIL_IBP_IS_VARIADIC_C __VA_ARGS__ \ + ) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 */ +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_PREPROCESSOR_IS_BEGIN_PARENS_HPP */ diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 92d1716..527fc22 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,9 +25,11 @@ test-suite preprocessor [ compile control.cpp ] [ compile debug.cpp ] [ compile facilities.cpp ] + [ compile isempty.cpp ] [ compile iteration.cpp ] [ compile list.cpp ] [ compile logical.cpp ] + [ compile punctuation.cpp ] [ compile repetition.cpp ] [ compile selection.cpp ] [ compile seq.cpp ] @@ -44,6 +46,7 @@ test-suite preprocessor_nvm [ compile control.cpp : BOOST_PP_VARIADICS=0 : control_nvm ] [ compile debug.cpp : BOOST_PP_VARIADICS=0 : debug_nvm ] [ compile facilities.cpp : BOOST_PP_VARIADICS=0 : facilities_nvm ] + [ compile isempty.cpp : BOOST_PP_VARIADICS=0 : isempty_nvm ] [ compile iteration.cpp : BOOST_PP_VARIADICS=0 : iteration_nvm ] [ compile list.cpp : BOOST_PP_VARIADICS=0 : list_nvm ] [ compile logical.cpp : BOOST_PP_VARIADICS=0 : logical_nvm ] @@ -80,6 +83,10 @@ test-suite preprocessor_c : gcc:-std=c99 : facilities_c ] + [ compile isempty.c + : gcc:-std=c99 + : isempty_c + ] [ compile list.c : gcc:-std=c99 : list_c @@ -88,6 +95,10 @@ test-suite preprocessor_c : gcc:-std=c99 : logical_c ] + [ compile punctuation.c + : gcc:-std=c99 + : punctuation_c + ] [ compile selection.c : gcc:-std=c99 : selection_c @@ -142,6 +153,11 @@ test-suite preprocessor_c_nvm gcc:-std=c99 : facilities_c_nvm ] + [ compile isempty.c + : BOOST_PP_VARIADICS=0 + gcc:-std=c99 + : isempty_c_nvm + ] [ compile list.c : BOOST_PP_VARIADICS=0 gcc:-std=c99 diff --git a/test/isempty.c b/test/isempty.c new file mode 100644 index 0000000..bd4c2c6 --- /dev/null +++ b/test/isempty.c @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty.cpp b/test/isempty.cpp new file mode 100644 index 0000000..a038bf4 --- /dev/null +++ b/test/isempty.cpp @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty.cxx b/test/isempty.cxx new file mode 100644 index 0000000..f2d7bc2 --- /dev/null +++ b/test/isempty.cxx @@ -0,0 +1,42 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include +# include +# include +# include + +#if BOOST_PP_VARIADICS + +#define DATA +#define OBJECT OBJECT2 +#define OBJECT2 +#define FUNC(x) FUNC2(x) +#define FUNC2(x) +#define FUNC_GEN3() anything +#define FUNC_GEN4(x) anything + +#if defined(BOOST_PP_VARIADICS_MSVC) + +#else + +#endif + +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END +BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END + +#endif diff --git a/test/punctuation.c b/test/punctuation.c new file mode 100644 index 0000000..8fc5dfc --- /dev/null +++ b/test/punctuation.c @@ -0,0 +1,14 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* Revised by Edward Diener (2011) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/punctuation.cpp b/test/punctuation.cpp new file mode 100644 index 0000000..8fc5dfc --- /dev/null +++ b/test/punctuation.cpp @@ -0,0 +1,14 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* Revised by Edward Diener (2011) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/punctuation.cxx b/test/punctuation.cxx new file mode 100644 index 0000000..3eb364b --- /dev/null +++ b/test/punctuation.cxx @@ -0,0 +1,42 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# if BOOST_PP_VARIADICS +# include +# include + +# define A_TUPLE (*,#,zz) +# define A_TUPLE2 (*,#,(zz,44,(e7))) +# define A_TUPLE_PLUS (mmf,34,^^,!) 456 +# define PLUS_ATUPLE yyt (j,ii%) +# define JDATA ggh +# define NOT_TUPLE y6() +# define NOT_TUPLE2 &(kkkgg,(e)) +# define A_SEQ (r)($)(#) +# define AN_ARRAY (4,(5,7,f,x)) +# define A_LIST (e,(g,(&,BOOST_PP_NIL))) + +// is_begin_parens + +BEGIN BOOST_PP_IS_BEGIN_PARENS() == 0 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(A_TUPLE) == 1 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(A_TUPLE2) == 1 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(A_TUPLE_PLUS) == 1 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(PLUS_ATUPLE) == 0 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(JDATA) == 0 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(NOT_TUPLE) == 0 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(NOT_TUPLE2) == 0 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(A_SEQ) == 1 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(AN_ARRAY) == 1 END +BEGIN BOOST_PP_IS_BEGIN_PARENS(A_LIST) == 1 END +BEGIN BOOST_PP_IS_BEGIN_PARENS((y)2(x)) == 1 END + +#endif From 6fe93a542dfa74df9c11375518aea0a682adef4b Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 28 Apr 2014 22:12:08 -0400 Subject: [PATCH 03/19] Added variadic version of BOOST_PP_EMPTY and added new is_empty tests. --- .../boost/preprocessor/facilities/empty.hpp | 7 ++++ .../facilities/is_empty_variadic.hpp | 6 +-- test/isempty.cxx | 40 ++++++++++++++++--- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/include/boost/preprocessor/facilities/empty.hpp b/include/boost/preprocessor/facilities/empty.hpp index 46db190..99e1daa 100644 --- a/include/boost/preprocessor/facilities/empty.hpp +++ b/include/boost/preprocessor/facilities/empty.hpp @@ -8,14 +8,21 @@ # */ # # /* Revised by Paul Mensonides (2002) */ +# /* Revised by Edward Diener (2014) */ # # /* See http://www.boost.org for most recent version. */ # # ifndef BOOST_PREPROCESSOR_FACILITIES_EMPTY_HPP # define BOOST_PREPROCESSOR_FACILITIES_EMPTY_HPP # +# include +# # /* BOOST_PP_EMPTY */ # +# if BOOST_PP_VARIADICS +# define BOOST_PP_EMPTY(...) +# else # define BOOST_PP_EMPTY() +# endif # # endif diff --git a/include/boost/preprocessor/facilities/is_empty_variadic.hpp b/include/boost/preprocessor/facilities/is_empty_variadic.hpp index 27b4ec0..c2700fe 100644 --- a/include/boost/preprocessor/facilities/is_empty_variadic.hpp +++ b/include/boost/preprocessor/facilities/is_empty_variadic.hpp @@ -16,10 +16,10 @@ # # if BOOST_PP_VARIADICS # +# include # include # include # -#define BOOST_PP_IS_EMPTY_GEN_ZERO(...) 0 #if BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 # #define BOOST_PP_IS_EMPTY(param) \ @@ -31,7 +31,7 @@ ) \ ) \ ( \ - BOOST_PP_IS_EMPTY_GEN_ZERO, \ + 0 BOOST_PP_EMPTY, \ BOOST_PP_DETAIL_IS_EMPTY_PROCESS \ ) \ (param) \ @@ -46,7 +46,7 @@ ) \ ) \ ( \ - BOOST_PP_IS_EMPTY_GEN_ZERO, \ + 0 BOOST_PP_EMPTY, \ BOOST_PP_DETAIL_IS_EMPTY_PROCESS \ ) \ (__VA_ARGS__) \ diff --git a/test/isempty.cxx b/test/isempty.cxx index f2d7bc2..94be43a 100644 --- a/test/isempty.cxx +++ b/test/isempty.cxx @@ -22,13 +22,43 @@ #define OBJECT2 #define FUNC(x) FUNC2(x) #define FUNC2(x) -#define FUNC_GEN3() anything -#define FUNC_GEN4(x) anything - +#define FUNC_GEN() () +#define FUNC_GEN2(x) () +#define FUNC_GEN3() (&) +#define FUNC_GEN4(x) (y) +#define FUNC_GEN5() (y,z) +#define FUNC_GEN6() anything +#define FUNC_GEN7(x) anything + #if defined(BOOST_PP_VARIADICS_MSVC) +#define FUNC_GEN8(x,y) (1,2,3) +#define FUNC_GEN9(x,y,z) anything + +/* These next five produce the wrong result in VC++ */ + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END + +/* This next should produce a compiler error but does not, and produces the incorrect result */ + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END + +/* This next should produce a compiler error but does not */ + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END + #else +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END + #endif BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END @@ -36,7 +66,7 @@ BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END -BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END -BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END #endif From c66ea5871fd44274f681f02323c4d46bdf394c7c Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Wed, 30 Apr 2014 16:06:49 -0400 Subject: [PATCH 04/19] Addition of is_empty tests and changes to rem processing as a workaround to VC++ problem. --- .../preprocessor/array/detail/get_data.hpp | 4 +- .../preprocessor/facilities/is_empty.hpp | 5 +- .../seq/detail/binary_transform.hpp | 14 ++- .../tuple/detail/is_single_return.hpp | 28 ++++++ include/boost/preprocessor/tuple/elem.hpp | 19 +--- include/boost/preprocessor/tuple/rem.hpp | 14 ++- .../variadic/detail/is_single_return.hpp | 28 ++++++ test/Jamfile.v2 | 92 ++++++++++++------ test/isempty.cpp | 2 +- test/isempty.cxx | 97 ++++++++++++++++--- test/isempty_failure.c | 12 +++ test/isempty_failure.cpp | 12 +++ test/isempty_failure.cxx | 25 +++++ test/isempty_failure2.c | 12 +++ test/isempty_failure2.cpp | 12 +++ test/isempty_failure2.cxx | 25 +++++ test/isempty_variadic_standard_failure.c | 12 +++ test/isempty_variadic_standard_failure.cpp | 12 +++ test/isempty_variadic_standard_failure.cxx | 25 +++++ test/isempty_variadic_standard_failure2.c | 12 +++ test/isempty_variadic_standard_failure2.cpp | 12 +++ test/isempty_variadic_standard_failure2.cxx | 25 +++++ test/tuple.cxx | 5 +- test/tuple_elem_bug_test.cxx | 38 ++++++++ 24 files changed, 476 insertions(+), 66 deletions(-) create mode 100644 include/boost/preprocessor/tuple/detail/is_single_return.hpp create mode 100644 include/boost/preprocessor/variadic/detail/is_single_return.hpp create mode 100644 test/isempty_failure.c create mode 100644 test/isempty_failure.cpp create mode 100644 test/isempty_failure.cxx create mode 100644 test/isempty_failure2.c create mode 100644 test/isempty_failure2.cpp create mode 100644 test/isempty_failure2.cxx create mode 100644 test/isempty_variadic_standard_failure.c create mode 100644 test/isempty_variadic_standard_failure.cpp create mode 100644 test/isempty_variadic_standard_failure.cxx create mode 100644 test/isempty_variadic_standard_failure2.c create mode 100644 test/isempty_variadic_standard_failure2.cpp create mode 100644 test/isempty_variadic_standard_failure2.cxx create mode 100644 test/tuple_elem_bug_test.cxx diff --git a/include/boost/preprocessor/array/detail/get_data.hpp b/include/boost/preprocessor/array/detail/get_data.hpp index d72547a..d978109 100644 --- a/include/boost/preprocessor/array/detail/get_data.hpp +++ b/include/boost/preprocessor/array/detail/get_data.hpp @@ -23,9 +23,7 @@ # # /* BOOST_PP_ARRAY_DETAIL_GET_DATA */ # -# define BOOST_PP_ARRAY_DETAIL_GET_DATA_REM(...) BOOST_PP_CAT(__VA_ARGS__,) -# define BOOST_PP_ARRAY_DETAIL_GET_DATA_TUPLE_REM(size) BOOST_PP_ARRAY_DETAIL_GET_DATA_REM -# define BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE(size, data) BOOST_PP_ARRAY_DETAIL_GET_DATA_TUPLE_REM(size) data +# define BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE(size, data) BOOST_PP_TUPLE_REM_CAT(size) data # define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY(size, data) BOOST_PP_TUPLE_REM(size) data # define BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO(size, data) \ BOOST_PP_IF \ diff --git a/include/boost/preprocessor/facilities/is_empty.hpp b/include/boost/preprocessor/facilities/is_empty.hpp index b1094d8..e7f821f 100644 --- a/include/boost/preprocessor/facilities/is_empty.hpp +++ b/include/boost/preprocessor/facilities/is_empty.hpp @@ -22,10 +22,13 @@ # else # # include -# include +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() # include # include +# else +# include # include +# endif # # /* BOOST_PP_IS_EMPTY */ # diff --git a/include/boost/preprocessor/seq/detail/binary_transform.hpp b/include/boost/preprocessor/seq/detail/binary_transform.hpp index 373e8a5..1c381a7 100644 --- a/include/boost/preprocessor/seq/detail/binary_transform.hpp +++ b/include/boost/preprocessor/seq/detail/binary_transform.hpp @@ -16,6 +16,9 @@ # include # include # include +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC +# include +# endif # # /* BOOST_PP_SEQ_BINARY_TRANSFORM */ # @@ -28,8 +31,15 @@ # define BOOST_PP_SEQ_BINARY_TRANSFORM(seq) BOOST_PP_CAT(BOOST_PP_SEQ_BINARY_TRANSFORM_A seq, 0) # endif # if BOOST_PP_VARIADICS -# define BOOST_PP_SEQ_BINARY_TRANSFORM_A(...) (BOOST_PP_REM, __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_B -# define BOOST_PP_SEQ_BINARY_TRANSFORM_B(...) (BOOST_PP_REM, __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_A +# if BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_SEQ_BINARY_TRANSFORM_GET_REM(...) \ + BOOST_PP_VARIADIC_IS_SINGLE_RETURN(BOOST_PP_REM_CAT,BOOST_PP_REM,__VA_ARGS__) \ + /**/ +# else +# define BOOST_PP_SEQ_BINARY_TRANSFORM_GET_REM(...) BOOST_PP_REM +# endif +# define BOOST_PP_SEQ_BINARY_TRANSFORM_A(...) (BOOST_PP_SEQ_BINARY_TRANSFORM_GET_REM(__VA_ARGS__), __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_B +# define BOOST_PP_SEQ_BINARY_TRANSFORM_B(...) (BOOST_PP_SEQ_BINARY_TRANSFORM_GET_REM(__VA_ARGS__), __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_A # else # define BOOST_PP_SEQ_BINARY_TRANSFORM_A(e) (BOOST_PP_REM, e)() BOOST_PP_SEQ_BINARY_TRANSFORM_B # define BOOST_PP_SEQ_BINARY_TRANSFORM_B(e) (BOOST_PP_REM, e)() BOOST_PP_SEQ_BINARY_TRANSFORM_A diff --git a/include/boost/preprocessor/tuple/detail/is_single_return.hpp b/include/boost/preprocessor/tuple/detail/is_single_return.hpp new file mode 100644 index 0000000..9ffa3cc --- /dev/null +++ b/include/boost/preprocessor/tuple/detail/is_single_return.hpp @@ -0,0 +1,28 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. * +# * Distributed under the Boost Software License, Version 1.0. (See * +# * accompanying file LICENSE_1_0.txt or copy at * +# * http://www.boost.org/LICENSE_1_0.txt) * +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_TUPLE_DETAIL_IS_SINGLE_RETURN_HPP +# define BOOST_PREPROCESSOR_TUPLE_DETAIL_IS_SINGLE_RETURN_HPP +# +# include +# include +# include +# include +# +# /* BOOST_PP_TUPLE_IS_SINGLE_RETURN */ +# +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_TUPLE_IS_SINGLE_RETURN(sr,nsr,tuple) \ + BOOST_PP_IIF(BOOST_PP_IS_1(BOOST_PP_TUPLE_SIZE(tuple)),sr,nsr) \ + /**/ +# endif /* BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC */ +# +# endif /* BOOST_PREPROCESSOR_TUPLE_DETAIL_IS_SINGLE_RETURN_HPP */ diff --git a/include/boost/preprocessor/tuple/elem.hpp b/include/boost/preprocessor/tuple/elem.hpp index 762a171..ee8f0bd 100644 --- a/include/boost/preprocessor/tuple/elem.hpp +++ b/include/boost/preprocessor/tuple/elem.hpp @@ -22,9 +22,7 @@ # include # # if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC -# include -# include -# include +# include # endif # # if BOOST_PP_VARIADICS @@ -33,21 +31,12 @@ # define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args) # define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,) /* - Use BOOST_PP_TUPLE_ELEM_O_2_CAT if it is a single element tuple ( which might be empty ) + Use BOOST_PP_REM_CAT if it is a single element tuple ( which might be empty ) else use BOOST_PP_REM. This fixes a VC++ problem with an empty tuple and BOOST_PP_TUPLE_ELEM - functionality. + functionality. See tuple_elem_bug_test.cxx. */ -# define BOOST_PP_TUPLE_ELEM_O_2_CAT(...) BOOST_PP_CAT(__VA_ARGS__,) -# define BOOST_PP_TUPLE_ELEM_O_2_SINGLE(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_TUPLE_ELEM_O_2_CAT tuple) -# define BOOST_PP_TUPLE_ELEM_O_2_ANY(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple) # define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) \ - BOOST_PP_IIF \ - ( \ - BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \ - BOOST_PP_TUPLE_ELEM_O_2_SINGLE, \ - BOOST_PP_TUPLE_ELEM_O_2_ANY \ - ) \ - (n, tuple) \ + BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_TUPLE_IS_SINGLE_RETURN(BOOST_PP_REM_CAT,BOOST_PP_REM,tuple) tuple) \ /**/ # else # define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__) diff --git a/include/boost/preprocessor/tuple/rem.hpp b/include/boost/preprocessor/tuple/rem.hpp index 270c31a..136d282 100644 --- a/include/boost/preprocessor/tuple/rem.hpp +++ b/include/boost/preprocessor/tuple/rem.hpp @@ -16,10 +16,17 @@ # include # include # include +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC +# include +# endif # # /* BOOST_PP_REM */ # # if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS_MSVC + /* To be used internally when __VA_ARGS__ is a single element */ +# define BOOST_PP_REM_CAT(...) BOOST_PP_CAT(__VA_ARGS__,) +# endif # define BOOST_PP_REM(...) __VA_ARGS__ # else # define BOOST_PP_REM(x) x @@ -31,6 +38,10 @@ VC++8.0 cannot handle the variadic version of BOOST_PP_TUPLE_REM(size) */ # if BOOST_PP_VARIADICS && !(BOOST_PP_VARIADICS_MSVC && _MSC_VER == 1400) +# if BOOST_PP_VARIADICS_MSVC + /* To be used internally when the size is 1 */ +# define BOOST_PP_TUPLE_REM_CAT(size) BOOST_PP_REM_CAT +# endif # define BOOST_PP_TUPLE_REM(size) BOOST_PP_REM # else # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() @@ -114,10 +125,11 @@ # define BOOST_PP_TUPLE_REM_CTOR(...) BOOST_PP_TUPLE_REM_CTOR_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_REM_CTOR_O_, __VA_ARGS__), (__VA_ARGS__)) # define BOOST_PP_TUPLE_REM_CTOR_I(m, args) BOOST_PP_TUPLE_REM_CTOR_II(m, args) # define BOOST_PP_TUPLE_REM_CTOR_II(m, args) BOOST_PP_CAT(m ## args,) +# define BOOST_PP_TUPLE_REM_CTOR_O_1(tuple) BOOST_PP_TUPLE_IS_SINGLE_RETURN(BOOST_PP_REM_CAT,BOOST_PP_REM,tuple) tuple # else # define BOOST_PP_TUPLE_REM_CTOR(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_REM_CTOR_O_, __VA_ARGS__)(__VA_ARGS__) +# define BOOST_PP_TUPLE_REM_CTOR_O_1(tuple) BOOST_PP_REM tuple # endif -# define BOOST_PP_TUPLE_REM_CTOR_O_1(tuple) BOOST_PP_REM tuple # define BOOST_PP_TUPLE_REM_CTOR_O_2(size, tuple) BOOST_PP_TUPLE_REM_CTOR_O_1(tuple) # else # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() diff --git a/include/boost/preprocessor/variadic/detail/is_single_return.hpp b/include/boost/preprocessor/variadic/detail/is_single_return.hpp new file mode 100644 index 0000000..491e06b --- /dev/null +++ b/include/boost/preprocessor/variadic/detail/is_single_return.hpp @@ -0,0 +1,28 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. * +# * Distributed under the Boost Software License, Version 1.0. (See * +# * accompanying file LICENSE_1_0.txt or copy at * +# * http://www.boost.org/LICENSE_1_0.txt) * +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_VARIADIC_DETAIL_IS_SINGLE_RETURN_HPP +# define BOOST_PREPROCESSOR_VARIADIC_DETAIL_IS_SINGLE_RETURN_HPP +# +# include +# include +# include +# include +# +# /* BOOST_PP_VARIADIC_IS_SINGLE_RETURN */ +# +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC +# define BOOST_PP_VARIADIC_IS_SINGLE_RETURN(sr,nsr,...) \ + BOOST_PP_IIF(BOOST_PP_IS_1(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)),sr,nsr) \ + /**/ +# endif /* BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC */ +# +# endif /* BOOST_PREPROCESSOR_VARIADIC_DETAIL_IS_SINGLE_RETURN_HPP */ diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 527fc22..ac61214 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -19,23 +19,22 @@ project preprocessor_tests : requirements on test-suite preprocessor : - [ compile arithmetic.cpp ] - [ compile array.cpp ] - [ compile comparison.cpp ] - [ compile control.cpp ] - [ compile debug.cpp ] - [ compile facilities.cpp ] - [ compile isempty.cpp ] - [ compile iteration.cpp ] - [ compile list.cpp ] - [ compile logical.cpp ] - [ compile punctuation.cpp ] - [ compile repetition.cpp ] - [ compile selection.cpp ] - [ compile seq.cpp ] - [ compile slot.cpp ] - [ compile tuple.cpp ] - [ compile variadic.cpp ] + [ compile arithmetic.cpp : gcc:-std=c++0x ] + [ compile array.cpp : gcc:-std=c++0x ] + [ compile comparison.cpp : gcc:-std=c++0x ] + [ compile control.cpp : gcc:-std=c++0x ] + [ compile debug.cpp : gcc:-std=c++0x ] + [ compile facilities.cpp : gcc:-std=c++0x ] + [ compile iteration.cpp : gcc:-std=c++0x ] + [ compile list.cpp : gcc:-std=c++0x ] + [ compile logical.cpp : gcc:-std=c++0x ] + [ compile punctuation.cpp : gcc:-std=c++0x ] + [ compile repetition.cpp : gcc:-std=c++0x ] + [ compile selection.cpp : gcc:-std=c++0x ] + [ compile seq.cpp : gcc:-std=c++0x ] + [ compile slot.cpp : gcc:-std=c++0x ] + [ compile tuple.cpp : gcc:-std=c++0x ] + [ compile variadic.cpp : gcc:-std=c++0x ] ; test-suite preprocessor_nvm @@ -46,7 +45,6 @@ test-suite preprocessor_nvm [ compile control.cpp : BOOST_PP_VARIADICS=0 : control_nvm ] [ compile debug.cpp : BOOST_PP_VARIADICS=0 : debug_nvm ] [ compile facilities.cpp : BOOST_PP_VARIADICS=0 : facilities_nvm ] - [ compile isempty.cpp : BOOST_PP_VARIADICS=0 : isempty_nvm ] [ compile iteration.cpp : BOOST_PP_VARIADICS=0 : iteration_nvm ] [ compile list.cpp : BOOST_PP_VARIADICS=0 : list_nvm ] [ compile logical.cpp : BOOST_PP_VARIADICS=0 : logical_nvm ] @@ -83,10 +81,6 @@ test-suite preprocessor_c : gcc:-std=c99 : facilities_c ] - [ compile isempty.c - : gcc:-std=c99 - : isempty_c - ] [ compile list.c : gcc:-std=c99 : list_c @@ -153,11 +147,6 @@ test-suite preprocessor_c_nvm gcc:-std=c99 : facilities_c_nvm ] - [ compile isempty.c - : BOOST_PP_VARIADICS=0 - gcc:-std=c99 - : isempty_c_nvm - ] [ compile list.c : BOOST_PP_VARIADICS=0 gcc:-std=c99 @@ -189,3 +178,52 @@ test-suite preprocessor_c_nvm : tuple_c_nvm ] ; + +# test-suite preprocessor_isempty +# : +# [ compile isempty.cpp : gcc:-std=c++0x ] +# [ compile-fail isempty_variadic_standard_failure.cpp : gcc:-std=c++0x ] +# [ compile-fail isempty_variadic_standard_failure2.cpp : gcc:-std=c++0x ] +# ; + +test-suite preprocessor_isempty_nvm + : + [ compile isempty.cpp : BOOST_PP_VARIADICS=0 : isempty_nvm ] + [ compile-fail isempty_failure.cpp : BOOST_PP_VARIADICS=0 : isempty_failure_nvm ] + [ compile-fail isempty_failure2.cpp : BOOST_PP_VARIADICS=0 : isempty_failure2_nvm ] + ; + +# test-suite preprocessor_isempty_c +# : +# [ compile isempty.c +# : gcc:-std=c99 +# : isempty_c +# ] +# [ compile-fail isempty_variadic_standard_failure.c +# : gcc:-std=c99 +# : isempty_variadic_standard_failure_c +# ] +# [ compile-fail isempty_variadic_standard_failure2.c +# : gcc:-std=c99 +# : isempty_variadic_standard_failure2_c +# ] +# ; + +test-suite preprocessor_isempty_c_nvm + : + [ compile isempty.c + : BOOST_PP_VARIADICS=0 + gcc:-std=c99 + : isempty_c_nvm + ] + [ compile-fail isempty_failure.c + : BOOST_PP_VARIADICS=0 + gcc:-std=c99 + : isempty_failure_c_nvm + ] + [ compile-fail isempty_failure2.c + : BOOST_PP_VARIADICS=0 + gcc:-std=c99 + : isempty_failure2_c_nvm + ] + ; diff --git a/test/isempty.cpp b/test/isempty.cpp index a038bf4..bd4c2c6 100644 --- a/test/isempty.cpp +++ b/test/isempty.cpp @@ -1,6 +1,6 @@ # /* ************************************************************************** # * * -# * (C) Copyright Paul Mensonides 2002. +# * (C) Copyright Edward Diener 2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/isempty.cxx b/test/isempty.cxx index 94be43a..cf2660f 100644 --- a/test/isempty.cxx +++ b/test/isempty.cxx @@ -11,12 +11,8 @@ # # include # include -# include -# include # include -#if BOOST_PP_VARIADICS - #define DATA #define OBJECT OBJECT2 #define OBJECT2 @@ -29,38 +25,53 @@ #define FUNC_GEN5() (y,z) #define FUNC_GEN6() anything #define FUNC_GEN7(x) anything - -#if defined(BOOST_PP_VARIADICS_MSVC) - #define FUNC_GEN8(x,y) (1,2,3) #define FUNC_GEN9(x,y,z) anything - -/* These next five produce the wrong result in VC++ */ +#define FUNC_GEN10(x) (y) data +#define NAME &name +#define ATUPLE (atuple) +#define ATUPLE_PLUS (atuple) data + +#if BOOST_PP_VARIADICS + +#if defined(BOOST_PP_VARIADICS_MSVC) /* Testing the VC++ variadic version */ + +/* INCORRECT */ BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END - -/* This next should produce a compiler error but does not, and produces the incorrect result */ - BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END -/* This next should produce a compiler error but does not */ +/* CORRECT */ BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END -#else +#else /* Testing the non-VC++ variadic version */ + +/* CORRECT */ BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END + +/* COMPILER ERROR */ + +// BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END +// BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END #endif +/* Testing the variadic version */ + +/* CORRECT */ + BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END @@ -68,5 +79,61 @@ BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END - +BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END +BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END +BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END + +#else + +#if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() /* Testing the VC++ non-variadic version */ + +/* INCORRECT */ + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END +BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END +BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END + +/* CORRECT */ + +BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END + +#else /* Testing the non-VC++ non-variadic version */ + +/* CORRECT */ + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END + +/* COMPILER ERROR */ + +// BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END +// BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END +// BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END + +#endif + +/* Testing the non-variadic version */ + +/* CORRECT */ + +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END +BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END + #endif diff --git a/test/isempty_failure.c b/test/isempty_failure.c new file mode 100644 index 0000000..db891ba --- /dev/null +++ b/test/isempty_failure.c @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_failure.cpp b/test/isempty_failure.cpp new file mode 100644 index 0000000..db891ba --- /dev/null +++ b/test/isempty_failure.cpp @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_failure.cxx b/test/isempty_failure.cxx new file mode 100644 index 0000000..f6a4179 --- /dev/null +++ b/test/isempty_failure.cxx @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include + +#if !BOOST_PP_VARIADICS && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) + +#define NAME &name + +BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END + +#else + +BEGIN 1 == 0 END + +#endif diff --git a/test/isempty_failure2.c b/test/isempty_failure2.c new file mode 100644 index 0000000..cb5aa2e --- /dev/null +++ b/test/isempty_failure2.c @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_failure2.cpp b/test/isempty_failure2.cpp new file mode 100644 index 0000000..cb5aa2e --- /dev/null +++ b/test/isempty_failure2.cpp @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_failure2.cxx b/test/isempty_failure2.cxx new file mode 100644 index 0000000..397774b --- /dev/null +++ b/test/isempty_failure2.cxx @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include + +#if !BOOST_PP_VARIADICS && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) + +#define ATUPLE_PLUS (atuple) data + +BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END + +#else + +BEGIN 1 == 0 END + +#endif diff --git a/test/isempty_variadic_standard_failure.c b/test/isempty_variadic_standard_failure.c new file mode 100644 index 0000000..36f6ff7 --- /dev/null +++ b/test/isempty_variadic_standard_failure.c @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_variadic_standard_failure.cpp b/test/isempty_variadic_standard_failure.cpp new file mode 100644 index 0000000..36f6ff7 --- /dev/null +++ b/test/isempty_variadic_standard_failure.cpp @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_variadic_standard_failure.cxx b/test/isempty_variadic_standard_failure.cxx new file mode 100644 index 0000000..d4403bf --- /dev/null +++ b/test/isempty_variadic_standard_failure.cxx @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include + +#if BOOST_PP_VARIADICS && !defined(BOOST_PP_VARIADICS_MSVC) + +#define FUNC_GEN8(x,y) (1,2,3) + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END + +#else + +BEGIN 1 == 0 END + +#endif diff --git a/test/isempty_variadic_standard_failure2.c b/test/isempty_variadic_standard_failure2.c new file mode 100644 index 0000000..a2aa690 --- /dev/null +++ b/test/isempty_variadic_standard_failure2.c @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_variadic_standard_failure2.cpp b/test/isempty_variadic_standard_failure2.cpp new file mode 100644 index 0000000..a2aa690 --- /dev/null +++ b/test/isempty_variadic_standard_failure2.cpp @@ -0,0 +1,12 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include diff --git a/test/isempty_variadic_standard_failure2.cxx b/test/isempty_variadic_standard_failure2.cxx new file mode 100644 index 0000000..38a6600 --- /dev/null +++ b/test/isempty_variadic_standard_failure2.cxx @@ -0,0 +1,25 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include + +#if BOOST_PP_VARIADICS && !defined(BOOST_PP_VARIADICS_MSVC) + +#define FUNC_GEN9(x,y,z) anything + +BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END + +#else + +BEGIN 1 == 0 END + +#endif diff --git a/test/tuple.cxx b/test/tuple.cxx index d5d941a..c315509 100644 --- a/test/tuple.cxx +++ b/test/tuple.cxx @@ -7,10 +7,12 @@ # * * # ************************************************************************** */ # -# /* Revised by Edward Diener (2011) */ +# /* Revised by Edward Diener (2011,2014) */ # # /* See http://www.boost.org for most recent version. */ # +# include +# include # include # include # include @@ -20,6 +22,7 @@ # include # endif # include +# include # define TUPLE (0, 1, 2, 3, 4, 5) # define TUPLE_LARGE (0, 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) diff --git a/test/tuple_elem_bug_test.cxx b/test/tuple_elem_bug_test.cxx new file mode 100644 index 0000000..56e36a6 --- /dev/null +++ b/test/tuple_elem_bug_test.cxx @@ -0,0 +1,38 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# include +# include +# include +# include + +#define TN_GEN_ONE(p) (1) +#define TN_GEN_ZERO(p) (0) +#define TN_TEST_ONE_MORE(parameter,ens) \ + BOOST_PP_IF \ + ( \ + BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(1,0,ens),0), \ + TN_GEN_ONE, \ + TN_GEN_ZERO \ + ) \ + (parameter) \ +/**/ +#define TN_TEST_ONE(parameter,ens) \ + BOOST_PP_TUPLE_ELEM \ + ( \ + 1, \ + 0, \ + TN_TEST_ONE_MORE(parameter,ens) \ + ) \ +/**/ + +BEGIN TN_TEST_ONE(A,(1)) == 1 END +BEGIN TN_TEST_ONE(A,()) == 0 END From fe2a9cbfcc680f310f1c45f86b3445efbfbd169a Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Wed, 30 Apr 2014 16:15:57 -0400 Subject: [PATCH 05/19] Added variadic is_empty tests. --- test/Jamfile.v2 | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ac61214..533e400 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -179,12 +179,12 @@ test-suite preprocessor_c_nvm ] ; -# test-suite preprocessor_isempty -# : -# [ compile isempty.cpp : gcc:-std=c++0x ] -# [ compile-fail isempty_variadic_standard_failure.cpp : gcc:-std=c++0x ] -# [ compile-fail isempty_variadic_standard_failure2.cpp : gcc:-std=c++0x ] -# ; +test-suite preprocessor_isempty + : + [ compile isempty.cpp : gcc:-std=c++0x ] + [ compile-fail isempty_variadic_standard_failure.cpp : gcc:-std=c++0x ] + [ compile-fail isempty_variadic_standard_failure2.cpp : gcc:-std=c++0x ] + ; test-suite preprocessor_isempty_nvm : @@ -193,21 +193,21 @@ test-suite preprocessor_isempty_nvm [ compile-fail isempty_failure2.cpp : BOOST_PP_VARIADICS=0 : isempty_failure2_nvm ] ; -# test-suite preprocessor_isempty_c -# : -# [ compile isempty.c -# : gcc:-std=c99 -# : isempty_c -# ] -# [ compile-fail isempty_variadic_standard_failure.c -# : gcc:-std=c99 -# : isempty_variadic_standard_failure_c -# ] -# [ compile-fail isempty_variadic_standard_failure2.c -# : gcc:-std=c99 -# : isempty_variadic_standard_failure2_c -# ] -# ; +test-suite preprocessor_isempty_c + : + [ compile isempty.c + : gcc:-std=c99 + : isempty_c + ] + [ compile-fail isempty_variadic_standard_failure.c + : gcc:-std=c99 + : isempty_variadic_standard_failure_c + ] + [ compile-fail isempty_variadic_standard_failure2.c + : gcc:-std=c99 + : isempty_variadic_standard_failure2_c + ] + ; test-suite preprocessor_isempty_c_nvm : From 4614c621307e96c1fd8408846f26ebc0d7f23775 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Thu, 1 May 2014 01:20:12 -0400 Subject: [PATCH 06/19] Updated tests for strict compilers or VC++ --- test/isempty.cxx | 6 ++++++ test/isempty_failure.cxx | 2 +- test/isempty_failure2.cxx | 2 +- test/isempty_variadic_standard_failure.cxx | 2 +- test/isempty_variadic_standard_failure2.cxx | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/test/isempty.cxx b/test/isempty.cxx index cf2660f..bcf5b48 100644 --- a/test/isempty.cxx +++ b/test/isempty.cxx @@ -9,6 +9,10 @@ # # /* See http://www.boost.org for most recent version. */ # +# include +# +#if (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) || (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) + # include # include # include @@ -137,3 +141,5 @@ BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END #endif + +#endif diff --git a/test/isempty_failure.cxx b/test/isempty_failure.cxx index f6a4179..72fbac3 100644 --- a/test/isempty_failure.cxx +++ b/test/isempty_failure.cxx @@ -12,7 +12,7 @@ # include # include -#if !BOOST_PP_VARIADICS && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) +#if !BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) #define NAME &name diff --git a/test/isempty_failure2.cxx b/test/isempty_failure2.cxx index 397774b..eded627 100644 --- a/test/isempty_failure2.cxx +++ b/test/isempty_failure2.cxx @@ -12,7 +12,7 @@ # include # include -#if !BOOST_PP_VARIADICS && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) +#if !BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) #define ATUPLE_PLUS (atuple) data diff --git a/test/isempty_variadic_standard_failure.cxx b/test/isempty_variadic_standard_failure.cxx index d4403bf..bfbbc9d 100644 --- a/test/isempty_variadic_standard_failure.cxx +++ b/test/isempty_variadic_standard_failure.cxx @@ -12,7 +12,7 @@ # include # include -#if BOOST_PP_VARIADICS && !defined(BOOST_PP_VARIADICS_MSVC) +#if BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && !defined(BOOST_PP_VARIADICS_MSVC) #define FUNC_GEN8(x,y) (1,2,3) diff --git a/test/isempty_variadic_standard_failure2.cxx b/test/isempty_variadic_standard_failure2.cxx index 38a6600..d730626 100644 --- a/test/isempty_variadic_standard_failure2.cxx +++ b/test/isempty_variadic_standard_failure2.cxx @@ -12,7 +12,7 @@ # include # include -#if BOOST_PP_VARIADICS && !defined(BOOST_PP_VARIADICS_MSVC) +#if BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && !defined(BOOST_PP_VARIADICS_MSVC) #define FUNC_GEN9(x,y,z) anything From 5c22605c3df5880c2d4f83e34165d0c5fa9b2e4c Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Thu, 1 May 2014 23:21:05 -0400 Subject: [PATCH 07/19] Removed tests which involve undefined behavior. --- test/Jamfile.v2 | 12 ------------ test/isempty.cxx | 2 +- test/isempty_failure.c | 12 ------------ test/isempty_failure.cpp | 12 ------------ test/isempty_failure.cxx | 25 ------------------------- test/isempty_failure2.c | 12 ------------ test/isempty_failure2.cpp | 12 ------------ test/isempty_failure2.cxx | 25 ------------------------- 8 files changed, 1 insertion(+), 111 deletions(-) delete mode 100644 test/isempty_failure.c delete mode 100644 test/isempty_failure.cpp delete mode 100644 test/isempty_failure.cxx delete mode 100644 test/isempty_failure2.c delete mode 100644 test/isempty_failure2.cpp delete mode 100644 test/isempty_failure2.cxx diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 533e400..5e91c86 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -189,8 +189,6 @@ test-suite preprocessor_isempty test-suite preprocessor_isempty_nvm : [ compile isempty.cpp : BOOST_PP_VARIADICS=0 : isempty_nvm ] - [ compile-fail isempty_failure.cpp : BOOST_PP_VARIADICS=0 : isempty_failure_nvm ] - [ compile-fail isempty_failure2.cpp : BOOST_PP_VARIADICS=0 : isempty_failure2_nvm ] ; test-suite preprocessor_isempty_c @@ -216,14 +214,4 @@ test-suite preprocessor_isempty_c_nvm gcc:-std=c99 : isempty_c_nvm ] - [ compile-fail isempty_failure.c - : BOOST_PP_VARIADICS=0 - gcc:-std=c99 - : isempty_failure_c_nvm - ] - [ compile-fail isempty_failure2.c - : BOOST_PP_VARIADICS=0 - gcc:-std=c99 - : isempty_failure2_c_nvm - ] ; diff --git a/test/isempty.cxx b/test/isempty.cxx index bcf5b48..d0c3776 100644 --- a/test/isempty.cxx +++ b/test/isempty.cxx @@ -119,7 +119,7 @@ BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END -/* COMPILER ERROR */ +/* UNDEFINED BEHAVIOR */ // BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END // BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END diff --git a/test/isempty_failure.c b/test/isempty_failure.c deleted file mode 100644 index db891ba..0000000 --- a/test/isempty_failure.c +++ /dev/null @@ -1,12 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Edward Diener 2014. -# * Distributed under the Boost Software License, Version 1.0. (See -# * accompanying file LICENSE_1_0.txt or copy at -# * http://www.boost.org/LICENSE_1_0.txt) -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include diff --git a/test/isempty_failure.cpp b/test/isempty_failure.cpp deleted file mode 100644 index db891ba..0000000 --- a/test/isempty_failure.cpp +++ /dev/null @@ -1,12 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Edward Diener 2014. -# * Distributed under the Boost Software License, Version 1.0. (See -# * accompanying file LICENSE_1_0.txt or copy at -# * http://www.boost.org/LICENSE_1_0.txt) -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include diff --git a/test/isempty_failure.cxx b/test/isempty_failure.cxx deleted file mode 100644 index 72fbac3..0000000 --- a/test/isempty_failure.cxx +++ /dev/null @@ -1,25 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Edward Diener 2014. -# * Distributed under the Boost Software License, Version 1.0. (See -# * accompanying file LICENSE_1_0.txt or copy at -# * http://www.boost.org/LICENSE_1_0.txt) -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -#if !BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) - -#define NAME &name - -BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END - -#else - -BEGIN 1 == 0 END - -#endif diff --git a/test/isempty_failure2.c b/test/isempty_failure2.c deleted file mode 100644 index cb5aa2e..0000000 --- a/test/isempty_failure2.c +++ /dev/null @@ -1,12 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Edward Diener 2014. -# * Distributed under the Boost Software License, Version 1.0. (See -# * accompanying file LICENSE_1_0.txt or copy at -# * http://www.boost.org/LICENSE_1_0.txt) -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include diff --git a/test/isempty_failure2.cpp b/test/isempty_failure2.cpp deleted file mode 100644 index cb5aa2e..0000000 --- a/test/isempty_failure2.cpp +++ /dev/null @@ -1,12 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Edward Diener 2014. -# * Distributed under the Boost Software License, Version 1.0. (See -# * accompanying file LICENSE_1_0.txt or copy at -# * http://www.boost.org/LICENSE_1_0.txt) -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include diff --git a/test/isempty_failure2.cxx b/test/isempty_failure2.cxx deleted file mode 100644 index eded627..0000000 --- a/test/isempty_failure2.cxx +++ /dev/null @@ -1,25 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Edward Diener 2014. -# * Distributed under the Boost Software License, Version 1.0. (See -# * accompanying file LICENSE_1_0.txt or copy at -# * http://www.boost.org/LICENSE_1_0.txt) -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -#if !BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()) && (~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()) - -#define ATUPLE_PLUS (atuple) data - -BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END - -#else - -BEGIN 1 == 0 END - -#endif From 7da9dbb7a9582c8a6df9636f3c6063ae781a5bf4 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Fri, 2 May 2014 02:59:10 -0400 Subject: [PATCH 08/19] Corrected calculation _msc_ver number. --- include/boost/preprocessor/array/detail/get_data.hpp | 4 ++-- include/boost/preprocessor/tuple/rem.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/preprocessor/array/detail/get_data.hpp b/include/boost/preprocessor/array/detail/get_data.hpp index d978109..fafa498 100644 --- a/include/boost/preprocessor/array/detail/get_data.hpp +++ b/include/boost/preprocessor/array/detail/get_data.hpp @@ -15,7 +15,7 @@ # include # include # -# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER != 1400 +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER > 1400 # include # include # include @@ -45,6 +45,6 @@ /**/ # else # define BOOST_PP_ARRAY_DETAIL_GET_DATA(size, data) BOOST_PP_TUPLE_REM(size) data -# endif /* BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER != 1400 */ +# endif /* BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER > 1400 */ # # endif /* BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP */ diff --git a/include/boost/preprocessor/tuple/rem.hpp b/include/boost/preprocessor/tuple/rem.hpp index 136d282..78e47fe 100644 --- a/include/boost/preprocessor/tuple/rem.hpp +++ b/include/boost/preprocessor/tuple/rem.hpp @@ -37,7 +37,7 @@ /* VC++8.0 cannot handle the variadic version of BOOST_PP_TUPLE_REM(size) */ -# if BOOST_PP_VARIADICS && !(BOOST_PP_VARIADICS_MSVC && _MSC_VER == 1400) +# if BOOST_PP_VARIADICS && !(BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400) # if BOOST_PP_VARIADICS_MSVC /* To be used internally when the size is 1 */ # define BOOST_PP_TUPLE_REM_CAT(size) BOOST_PP_REM_CAT From dec4cfd27394f3b5103c30a2bb6ba8ea65fd5716 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Fri, 2 May 2014 20:17:08 -0400 Subject: [PATCH 09/19] Further tests of changes involving empty data. --- test/array.cxx | 5 +++++ test/list.cxx | 2 ++ test/seq.cxx | 3 +++ test/tuple.cxx | 13 ++++++++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/array.cxx b/test/array.cxx index ae3a275..a764077 100644 --- a/test/array.cxx +++ b/test/array.cxx @@ -21,6 +21,7 @@ # include # endif +# define ARRAY_EMPTY (0, ()) # define ARRAY (3, (0, 1, 2)) # define ARRAY_LARGE (33, (0, 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)) # define ARRAY_VERY_LARGE (64, (0, 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)) @@ -124,15 +125,19 @@ BEGIN BOOST_PP_ARRAY_ELEM(55, BOOST_PP_ARRAY_POP_FRONT(ARRAY_VERY_LARGE)) == 56 BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_PUSH_BACK(ARRAY, 3)) == 4 END BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_PUSH_BACK(ARRAY_LARGE, 33)) == 34 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_PUSH_BACK(ARRAY_EMPTY, 10)) == 1 END BEGIN BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_PUSH_BACK(ARRAY, 3)) == 0 END BEGIN BOOST_PP_ARRAY_ELEM(33, BOOST_PP_ARRAY_PUSH_BACK(ARRAY_LARGE, 33)) == 33 END +BEGIN BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_PUSH_BACK(ARRAY_EMPTY, 136)) == 136 END // push_front BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_PUSH_FRONT(ARRAY, 555)) == 4 END BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_PUSH_FRONT(ARRAY_LARGE, 666)) == 34 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_PUSH_FRONT(ARRAY_EMPTY, 10)) == 1 END BEGIN BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_PUSH_FRONT(ARRAY, 555)) == 555 END BEGIN BOOST_PP_ARRAY_ELEM(33, BOOST_PP_ARRAY_PUSH_FRONT(ARRAY_LARGE, 33)) == 32 END +BEGIN BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_PUSH_FRONT(ARRAY_EMPTY, 136)) == 136 END // remove diff --git a/test/list.cxx b/test/list.cxx index db6c432..2f16086 100644 --- a/test/list.cxx +++ b/test/list.cxx @@ -19,6 +19,7 @@ # include # include # include +# include # include # include # include @@ -77,4 +78,5 @@ BEGIN BOOST_PP_LIST_FOR_EACH_PRODUCT(F2, 2, ( (1, (0, BOOST_PP_NIL)), (2, (3, BO BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_APPEND_D, BOOST_PP_NIL, LL)) == 0x0a1b2c3d END BEGIN BOOST_PP_ARRAY_ELEM(2, BOOST_PP_LIST_TO_ARRAY(LIST)) == 5 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_LIST_TO_ARRAY(LISTNIL)) == 0 END BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_LIST_TO_SEQ(LIST)) == 2 END diff --git a/test/seq.cxx b/test/seq.cxx index c64085d..b73ea99 100644 --- a/test/seq.cxx +++ b/test/seq.cxx @@ -16,6 +16,7 @@ # include # include # include +# include # include # include # include @@ -23,6 +24,7 @@ # include # include +# define SEQ_NONE () # define SEQ (4)(1)(5)(2) # define SEQVAR (4,5,8,3,61)(1,0)(5,22,43)(2)(17,45,33) @@ -98,6 +100,7 @@ BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~), BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~), LL))) == 9 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_SEQ_TO_LIST(SEQ), 2) == 5 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_LIST_AT(BOOST_PP_SEQ_TO_LIST(SEQ_NONE),0)) == 1 END #if BOOST_PP_VARIADICS diff --git a/test/tuple.cxx b/test/tuple.cxx index c315509..9187ff5 100644 --- a/test/tuple.cxx +++ b/test/tuple.cxx @@ -17,6 +17,7 @@ # include # include # include +# include # if BOOST_PP_VARIADICS # include # include @@ -25,6 +26,7 @@ # include # define TUPLE (0, 1, 2, 3, 4, 5) +# define TUPLE_NONE () # define TUPLE_LARGE (0, 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) # define TUPLE_VERY_LARGE (0, 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) # define T2 (+3, /2, +6) @@ -47,6 +49,7 @@ // elem +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1, 0, TUPLE_NONE)) == 1 END BEGIN BOOST_PP_TUPLE_ELEM(6, 3, TUPLE) == 3 END BEGIN BOOST_PP_TUPLE_ELEM(6, 5, TUPLE) == 5 END BEGIN BOOST_PP_TUPLE_ELEM(33, 15, TUPLE_LARGE) == 15 END @@ -92,6 +95,7 @@ BEGIN BOOST_PP_SEQ_ELEM(55,BOOST_PP_TUPLE_TO_SEQ(64,TUPLE_VERY_LARGE)) == 55 END // elem +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0, TUPLE_NONE)) == 1 END BEGIN BOOST_PP_TUPLE_ELEM(3, TUPLE) == 3 END BEGIN BOOST_PP_TUPLE_ELEM(5, TUPLE) == 5 END BEGIN BOOST_PP_TUPLE_ELEM(15, TUPLE_LARGE) == 15 END @@ -161,7 +165,7 @@ BEGIN BOOST_PP_TUPLE_ELEM(33, BOOST_PP_TUPLE_PUSH_FRONT(TUPLE_LARGE, 33)) == 32 // rem -#if BOOST_PP_VARIADICS_MSVC && _MSC_VER == 1400 +#if BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM(6)(0, 1, 2, 3, 4, 5)) == 6 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM(33)(0, 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 END @@ -169,6 +173,12 @@ BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM(64)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9 #else +#if BOOST_PP_VARIADICS_MSVC +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_REM_CAT() TUPLE_NONE) == 1 END +#else +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_REM() TUPLE_NONE) == 1 END +#endif + BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM()(0, 1, 2, 3, 4, 5)) == 6 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM()(0, 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 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM()(0, 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 END @@ -177,6 +187,7 @@ BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM()(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // rem_ctor +BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM_CTOR(TUPLE_NONE)) == 1 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM_CTOR(TUPLE)) == 6 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM_CTOR(TUPLE_LARGE)) == 33 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_TUPLE_REM_CTOR(TUPLE_VERY_LARGE)) == 64 END From 70e775452ace77c19506282d84be29eade10b636 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 3 May 2014 02:15:47 -0400 Subject: [PATCH 10/19] Added remove_parens and tests. --- include/boost/preprocessor/punctuation.hpp | 1 + .../punctuation/remove_parens.hpp | 39 +++++++++++++++++++ test/punctuation.cxx | 12 ++++++ 3 files changed, 52 insertions(+) create mode 100644 include/boost/preprocessor/punctuation/remove_parens.hpp diff --git a/include/boost/preprocessor/punctuation.hpp b/include/boost/preprocessor/punctuation.hpp index a96bbff..56dd064 100644 --- a/include/boost/preprocessor/punctuation.hpp +++ b/include/boost/preprocessor/punctuation.hpp @@ -17,5 +17,6 @@ # include # include # include +# include # # endif diff --git a/include/boost/preprocessor/punctuation/remove_parens.hpp b/include/boost/preprocessor/punctuation/remove_parens.hpp new file mode 100644 index 0000000..4700936 --- /dev/null +++ b/include/boost/preprocessor/punctuation/remove_parens.hpp @@ -0,0 +1,39 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Edward Diener 2014. +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +#ifndef BOOST_PREPROCESSOR_REMOVE_PARENS_HPP +#define BOOST_PREPROCESSOR_REMOVE_PARENS_HPP + +#include + +#if BOOST_PP_VARIADICS + +#include +#include +#include +#include + +#define BOOST_PP_REMOVE_PARENS(param) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_IS_BEGIN_PARENS(param), \ + BOOST_PP_REMOVE_PARENS_DO, \ + BOOST_PP_IDENTITY \ + ) \ + (param)() \ +/**/ + +#define BOOST_PP_REMOVE_PARENS_DO(param) \ + BOOST_PP_IDENTITY(BOOST_PP_TUPLE_ENUM(param)) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_PREPROCESSOR_REMOVE_PARENS_HPP */ diff --git a/test/punctuation.cxx b/test/punctuation.cxx index 3eb364b..8e60e9a 100644 --- a/test/punctuation.cxx +++ b/test/punctuation.cxx @@ -23,6 +23,11 @@ # define A_SEQ (r)($)(#) # define AN_ARRAY (4,(5,7,f,x)) # define A_LIST (e,(g,(&,BOOST_PP_NIL))) +# define DATA (5 + 3) * 4 +# define DATA2 4 * (5 + 3) +# define DATA3 4 * (5 + 3) * (2 + 1) +# define DATA4 (5 + 3) * (2 + 1) * 4 + // is_begin_parens @@ -39,4 +44,11 @@ BEGIN BOOST_PP_IS_BEGIN_PARENS(AN_ARRAY) == 1 END BEGIN BOOST_PP_IS_BEGIN_PARENS(A_LIST) == 1 END BEGIN BOOST_PP_IS_BEGIN_PARENS((y)2(x)) == 1 END +// remove_parens + +BEGIN BOOST_PP_REMOVE_PARENS(DATA) == 17 END +BEGIN BOOST_PP_REMOVE_PARENS(DATA2)== 32 END +BEGIN BOOST_PP_REMOVE_PARENS(DATA3)== 96 END +BEGIN BOOST_PP_REMOVE_PARENS(DATA4)== 41 END + #endif From 697ebcd840e4646cca46b43ab44784a724bbf6b3 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sun, 4 May 2014 03:07:00 -0400 Subject: [PATCH 11/19] Fixes for empty conversions and tests for empty conversions. --- include/boost/preprocessor/array/to_list.hpp | 20 +++++++++++-- include/boost/preprocessor/list/to_array.hpp | 17 +++++++++++ include/boost/preprocessor/tuple/to_seq.hpp | 3 ++ test/array.cxx | 10 +++++++ test/list.cxx | 30 +++++++++++++------- test/seq.cxx | 15 ++++++++++ test/tuple.cxx | 15 ++++++++++ 7 files changed, 96 insertions(+), 14 deletions(-) diff --git a/include/boost/preprocessor/array/to_list.hpp b/include/boost/preprocessor/array/to_list.hpp index 9198561..4cb45b6 100644 --- a/include/boost/preprocessor/array/to_list.hpp +++ b/include/boost/preprocessor/array/to_list.hpp @@ -15,19 +15,33 @@ # # include # include +# include +# include # include # # /* BOOST_PP_ARRAY_TO_LIST */ # +# define BOOST_PP_ARRAY_TO_LIST(array) \ + BOOST_PP_IF \ + ( \ + BOOST_PP_ARRAY_SIZE(array), \ + BOOST_PP_ARRAY_TO_LIST_DO, \ + BOOST_PP_ARRAY_TO_LIST_EMPTY \ + ) \ + (array) \ +/**/ +# +# define BOOST_PP_ARRAY_TO_LIST_EMPTY(array) BOOST_PP_NIL +# # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() -# define BOOST_PP_ARRAY_TO_LIST(array) BOOST_PP_ARRAY_TO_LIST_I(BOOST_PP_TUPLE_TO_LIST, array) +# define BOOST_PP_ARRAY_TO_LIST_DO(array) BOOST_PP_ARRAY_TO_LIST_I(BOOST_PP_TUPLE_TO_LIST, array) # define BOOST_PP_ARRAY_TO_LIST_I(m, args) BOOST_PP_ARRAY_TO_LIST_II(m, args) # define BOOST_PP_ARRAY_TO_LIST_II(m, args) BOOST_PP_CAT(m ## args,) # elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() -# define BOOST_PP_ARRAY_TO_LIST(array) BOOST_PP_ARRAY_TO_LIST_I(array) +# define BOOST_PP_ARRAY_TO_LIST_DO(array) BOOST_PP_ARRAY_TO_LIST_I(array) # define BOOST_PP_ARRAY_TO_LIST_I(array) BOOST_PP_TUPLE_TO_LIST ## array # else -# define BOOST_PP_ARRAY_TO_LIST(array) BOOST_PP_TUPLE_TO_LIST array +# define BOOST_PP_ARRAY_TO_LIST_DO(array) BOOST_PP_TUPLE_TO_LIST array # endif # # endif diff --git a/include/boost/preprocessor/list/to_array.hpp b/include/boost/preprocessor/list/to_array.hpp index 5a0433d..3711d4c 100644 --- a/include/boost/preprocessor/list/to_array.hpp +++ b/include/boost/preprocessor/list/to_array.hpp @@ -21,10 +21,27 @@ # include # include # include +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && (_MSC_VER <= 1400) +# include +# endif # # /* BOOST_PP_LIST_TO_ARRAY */ # +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && (_MSC_VER <= 1400) +# define BOOST_PP_LIST_TO_ARRAY(list) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_LIST_IS_NIL(list), \ + BOOST_PP_LIST_TO_ARRAY_VC8ORLESS_EMPTY, \ + BOOST_PP_LIST_TO_ARRAY_VC8ORLESS_DO \ + ) \ + (list) \ +/**/ +# define BOOST_PP_LIST_TO_ARRAY_VC8ORLESS_EMPTY(list) (0,()) +# define BOOST_PP_LIST_TO_ARRAY_VC8ORLESS_DO(list) BOOST_PP_LIST_TO_ARRAY_I(BOOST_PP_WHILE, list) +# else # define BOOST_PP_LIST_TO_ARRAY(list) BOOST_PP_LIST_TO_ARRAY_I(BOOST_PP_WHILE, list) +# endif # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() # define BOOST_PP_LIST_TO_ARRAY_I(w, list) \ diff --git a/include/boost/preprocessor/tuple/to_seq.hpp b/include/boost/preprocessor/tuple/to_seq.hpp index 8bd8485..a53f5a0 100644 --- a/include/boost/preprocessor/tuple/to_seq.hpp +++ b/include/boost/preprocessor/tuple/to_seq.hpp @@ -48,6 +48,9 @@ # endif # endif # +/* An empty array can be passed */ +# define BOOST_PP_TUPLE_TO_SEQ_0() () +# # define BOOST_PP_TUPLE_TO_SEQ_1(e0) (e0) # define BOOST_PP_TUPLE_TO_SEQ_2(e0, e1) (e0)(e1) # define BOOST_PP_TUPLE_TO_SEQ_3(e0, e1, e2) (e0)(e1)(e2) diff --git a/test/array.cxx b/test/array.cxx index a764077..fd189c7 100644 --- a/test/array.cxx +++ b/test/array.cxx @@ -13,9 +13,13 @@ # # include # include +# include # include +# include # include +# include # include +# include # if BOOST_PP_VARIADICS # include # include @@ -67,6 +71,7 @@ BEGIN BOOST_PP_LIST_AT(BOOST_PP_ARRAY_TO_LIST(ARRAY), 1) == 1 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_ARRAY_TO_LIST((5, (0, 1, 2, 3, 4))), 4) == 4 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_ARRAY_TO_LIST((33, (0, 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))), 26) == 26 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_ARRAY_TO_LIST(ARRAY_VERY_LARGE), 60) == 60 END +BEGIN BOOST_PP_LIST_SIZE(BOOST_PP_ARRAY_TO_LIST(ARRAY_EMPTY)) == 0 END // to_seq @@ -74,6 +79,8 @@ BEGIN BOOST_PP_SEQ_ELEM(0, BOOST_PP_ARRAY_TO_SEQ(ARRAY)) == 0 END BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_ARRAY_TO_SEQ((5, (0, 1, 2, 3, 4)))) == 3 END BEGIN BOOST_PP_SEQ_ELEM(17, BOOST_PP_ARRAY_TO_SEQ(ARRAY_LARGE)) == 17 END BEGIN BOOST_PP_SEQ_ELEM(42, BOOST_PP_ARRAY_TO_SEQ((64, (0, 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)))) == 42 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_SEQ_ELEM(0,BOOST_PP_ARRAY_TO_SEQ(ARRAY_EMPTY))) == 1 END +BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_ARRAY_TO_SEQ(ARRAY_EMPTY)) == 1 END // to_tuple @@ -83,6 +90,8 @@ BEGIN BOOST_PP_TUPLE_ELEM(2, BOOST_PP_ARRAY_TO_TUPLE(ARRAY)) == 2 END BEGIN BOOST_PP_TUPLE_ELEM(1, BOOST_PP_ARRAY_TO_TUPLE((5, (0, 1, 2, 3, 4)))) == 1 END BEGIN BOOST_PP_TUPLE_ELEM(26, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_LARGE)) == 26 END BEGIN BOOST_PP_TUPLE_ELEM(37, BOOST_PP_ARRAY_TO_TUPLE((64, (0, 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)))) == 37 END +BEGIN BOOST_PP_TUPLE_SIZE(BOOST_PP_ARRAY_TO_TUPLE(ARRAY_EMPTY)) == 1 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_EMPTY))) == 1 END # else @@ -90,6 +99,7 @@ BEGIN BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_ARRAY_TO_TUPLE(ARRAY)) == 2 END BEGIN BOOST_PP_TUPLE_ELEM(5, 1, BOOST_PP_ARRAY_TO_TUPLE((5, (0, 1, 2, 3, 4)))) == 1 END BEGIN BOOST_PP_TUPLE_ELEM(33, 26, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_LARGE)) == 26 END BEGIN BOOST_PP_TUPLE_ELEM(64, 37, BOOST_PP_ARRAY_TO_TUPLE((64, (0, 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)))) == 37 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1, 0, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_EMPTY))) == 1 END # endif diff --git a/test/list.cxx b/test/list.cxx index 2f16086..1e33274 100644 --- a/test/list.cxx +++ b/test/list.cxx @@ -16,18 +16,27 @@ # include # include # include +# include # include # include +# include # include # include # include +# include # include # include # define LISTNIL BOOST_PP_NIL # define LIST (4, (1, (5, (2, BOOST_PP_NIL)))) - # define REVERSAL(d, x, y) BOOST_PP_SUB_D(d, y, x) +# define F1(r, state, x) + x + state +# define FI2(r, state, i, x) BOOST_PP_IIF(BOOST_PP_EQUAL(i,1),+ x + x + state,+ x + state) +# define F2(r, x) + BOOST_PP_TUPLE_ELEM(2, 0, x) + 2 - BOOST_PP_TUPLE_ELEM(2, 1, x) +# define L1 (0, (x, BOOST_PP_NIL)) +# define L2 (a, (1, (b, (2, BOOST_PP_NIL)))) +# define L3 (c, (3, (d, BOOST_PP_NIL))) +# define LL (L1, (L2, (L3, BOOST_PP_NIL))) BEGIN BOOST_PP_LIST_FIRST(LIST) == 4 END BEGIN BOOST_PP_LIST_IS_CONS(LIST) == 1 END @@ -52,31 +61,30 @@ BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FIRST_N(2, LIST)) == 41 END BEGIN BOOST_PP_LIST_AT(LIST, 2) == 5 END BEGIN BOOST_PP_LIST_SIZE(LIST) == 4 END +BEGIN BOOST_PP_LIST_SIZE(LISTNIL) == 0 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D, 2, LIST)) == 6374 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_APPEND(BOOST_PP_LIST_REST(LIST), LIST)) == 1524152 END -# define F1(r, state, x) + x + state -# define FI2(r, state, i, x) BOOST_PP_IIF(BOOST_PP_EQUAL(i,1),+ x + x + state,+ x + state) - BEGIN BOOST_PP_LIST_FOR_EACH(F1, 1, LIST) == 16 END BEGIN BOOST_PP_LIST_FOR_EACH_I(FI2, 1, LIST) == 17 END BEGIN BOOST_PP_TUPLE_ELEM(4, 3, BOOST_PP_LIST_TO_TUPLE(LIST)) == 2 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1, 0, BOOST_PP_LIST_TO_TUPLE(LISTNIL))) == 1 END + +#if BOOST_PP_VARIADICS + +BEGIN BOOST_PP_TUPLE_SIZE(BOOST_PP_LIST_TO_TUPLE(LISTNIL)) == 1 END + +#endif BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D, 3, LIST)) == 45 END -# define F2(r, x) + BOOST_PP_TUPLE_ELEM(2, 0, x) + 2 - BOOST_PP_TUPLE_ELEM(2, 1, x) BEGIN BOOST_PP_LIST_FOR_EACH_PRODUCT(F2, 2, ( (1, (0, BOOST_PP_NIL)), (2, (3, BOOST_PP_NIL)) )) == 0 END -# define L1 (0, (x, BOOST_PP_NIL)) -# define L2 (a, (1, (b, (2, BOOST_PP_NIL)))) -# define L3 (c, (3, (d, BOOST_PP_NIL))) - -# define LL (L1, (L2, (L3, BOOST_PP_NIL))) - BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_APPEND_D, BOOST_PP_NIL, LL)) == 0x0a1b2c3d END BEGIN BOOST_PP_ARRAY_ELEM(2, BOOST_PP_LIST_TO_ARRAY(LIST)) == 5 END BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_LIST_TO_ARRAY(LISTNIL)) == 0 END BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_LIST_TO_SEQ(LIST)) == 2 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_LIST_TO_SEQ(LISTNIL)) == 1 END diff --git a/test/seq.cxx b/test/seq.cxx index b73ea99..ae37291 100644 --- a/test/seq.cxx +++ b/test/seq.cxx @@ -19,8 +19,11 @@ # include # include # include +# include # include +# include # include +# include # include # include @@ -55,8 +58,19 @@ BEGIN BOOST_PP_SEQ_FOR_EACH(F1, 1, SEQ) == 16 END BEGIN BOOST_PP_SEQ_FOR_EACH_I(FI2, 1, SEQ) == 21 END BEGIN BOOST_PP_TUPLE_ELEM(4, 3, BOOST_PP_SEQ_TO_TUPLE(SEQ)) == 2 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1, 0, BOOST_PP_SEQ_TO_TUPLE(SEQ_NONE))) == 1 END + +#if BOOST_PP_VARIADICS + +BEGIN BOOST_PP_TUPLE_SIZE(BOOST_PP_SEQ_TO_TUPLE(SEQ_NONE)) == 1 END + +#endif + BEGIN BOOST_PP_ARRAY_ELEM(3, BOOST_PP_SEQ_TO_ARRAY(SEQ)) == 2 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_ARRAY_ELEM(0, BOOST_PP_SEQ_TO_ARRAY(SEQ_NONE))) == 1 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_SEQ_TO_ARRAY(SEQ_NONE)) == 1 END + # define LESS_S(s, x, y) BOOST_PP_LESS(x, y) BEGIN BOOST_PP_SEQ_CAT(BOOST_PP_SEQ_FILTER(LESS_S, 3, SEQ)) == 45 END @@ -101,6 +115,7 @@ BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_TAIL(BOOST_PP_SEQ_FOLD_LEFT(SEQ_APPEND, (~) BEGIN BOOST_PP_LIST_AT(BOOST_PP_SEQ_TO_LIST(SEQ), 2) == 5 END BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_LIST_AT(BOOST_PP_SEQ_TO_LIST(SEQ_NONE),0)) == 1 END +BEGIN BOOST_PP_LIST_SIZE(BOOST_PP_SEQ_TO_LIST(SEQ_NONE)) == 1 END #if BOOST_PP_VARIADICS diff --git a/test/tuple.cxx b/test/tuple.cxx index 9187ff5..68d7209 100644 --- a/test/tuple.cxx +++ b/test/tuple.cxx @@ -15,8 +15,11 @@ # include # include # include +# include # include +# include # include +# include # include # if BOOST_PP_VARIADICS # include @@ -78,18 +81,24 @@ BEGIN TEST_EAT_VERY_LARGE == 8 END BEGIN BOOST_PP_ARRAY_ELEM(3,BOOST_PP_TUPLE_TO_ARRAY(6,TUPLE)) == 3 END BEGIN BOOST_PP_ARRAY_ELEM(29,BOOST_PP_TUPLE_TO_ARRAY(33,TUPLE_LARGE)) == 29 END BEGIN BOOST_PP_ARRAY_ELEM(61,BOOST_PP_TUPLE_TO_ARRAY(64,TUPLE_VERY_LARGE)) == 61 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_ARRAY_ELEM(0,BOOST_PP_TUPLE_TO_ARRAY(1,TUPLE_NONE))) == 1 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_TUPLE_TO_ARRAY(1,TUPLE_NONE)) == 1 END // to_list BEGIN BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(6,TUPLE), 2) == 2 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(33,TUPLE_LARGE), 19) == 19 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(64,TUPLE_VERY_LARGE), 62) == 62 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(1,TUPLE_NONE), 0)) == 1 END +BEGIN BOOST_PP_LIST_SIZE(BOOST_PP_TUPLE_TO_LIST(1,TUPLE_NONE)) == 1 END // to_seq BEGIN BOOST_PP_SEQ_ELEM(4,BOOST_PP_TUPLE_TO_SEQ(6,TUPLE)) == 4 END BEGIN BOOST_PP_SEQ_ELEM(31,BOOST_PP_TUPLE_TO_SEQ(33,TUPLE_LARGE)) == 31 END BEGIN BOOST_PP_SEQ_ELEM(55,BOOST_PP_TUPLE_TO_SEQ(64,TUPLE_VERY_LARGE)) == 55 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_SEQ_ELEM(0,BOOST_PP_TUPLE_TO_SEQ(1,TUPLE_NONE))) == 1 END +BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_TO_SEQ(1,TUPLE_NONE)) == 1 END #if BOOST_PP_VARIADICS @@ -220,17 +229,23 @@ BEGIN BOOST_PP_TUPLE_SIZE(TUPLE_VERY_LARGE) == 64 END BEGIN BOOST_PP_ARRAY_ELEM(3,BOOST_PP_TUPLE_TO_ARRAY(TUPLE)) == 3 END BEGIN BOOST_PP_ARRAY_ELEM(29,BOOST_PP_TUPLE_TO_ARRAY(TUPLE_LARGE)) == 29 END BEGIN BOOST_PP_ARRAY_ELEM(61,BOOST_PP_TUPLE_TO_ARRAY(TUPLE_VERY_LARGE)) == 61 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_ARRAY_ELEM(0,BOOST_PP_TUPLE_TO_ARRAY(TUPLE_NONE))) == 1 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_TUPLE_TO_ARRAY(TUPLE_NONE)) == 1 END // to_tuple BEGIN BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(TUPLE), 2) == 2 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(TUPLE_LARGE), 19) == 19 END BEGIN BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(TUPLE_VERY_LARGE), 62) == 62 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(TUPLE_NONE), 0)) == 1 END +BEGIN BOOST_PP_LIST_SIZE(BOOST_PP_TUPLE_TO_LIST(TUPLE_NONE)) == 1 END // to_seq BEGIN BOOST_PP_SEQ_ELEM(4,BOOST_PP_TUPLE_TO_SEQ(TUPLE)) == 4 END BEGIN BOOST_PP_SEQ_ELEM(31,BOOST_PP_TUPLE_TO_SEQ(TUPLE_LARGE)) == 31 END BEGIN BOOST_PP_SEQ_ELEM(55,BOOST_PP_TUPLE_TO_SEQ(TUPLE_VERY_LARGE)) == 55 END +BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_SEQ_ELEM(0,BOOST_PP_TUPLE_TO_SEQ(TUPLE_NONE))) == 1 END +BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_TO_SEQ(TUPLE_NONE)) == 1 END #endif From 181a88db7e5b578d16d7d26a07ee5bd093942d5b Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sun, 4 May 2014 23:55:53 -0400 Subject: [PATCH 12/19] Added further tests for empty lists and arrays. --- test/array.cxx | 6 ++++++ test/list.cxx | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/test/array.cxx b/test/array.cxx index fd189c7..975aaa3 100644 --- a/test/array.cxx +++ b/test/array.cxx @@ -47,6 +47,7 @@ BEGIN BOOST_PP_ARRAY_SIZE(ARRAY_LARGE) == 33 END BEGIN BOOST_PP_ARRAY_SIZE((33, (0, 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 END BEGIN BOOST_PP_ARRAY_SIZE(ARRAY_VERY_LARGE) == 64 END BEGIN BOOST_PP_ARRAY_SIZE((64, (0, 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 END +BEGIN BOOST_PP_ARRAY_SIZE(ARRAY_EMPTY) == 0 END // enum @@ -62,6 +63,7 @@ BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_ARRAY_ENUM((5, (0, 1, 2, 3, 4)))) == 5 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_ARRAY_ENUM(ARRAY_LARGE)) == 33 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_ARRAY_ENUM(ARRAY_VERY_LARGE)) == 64 END BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_ARRAY_ENUM((64, (0, 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 END +BEGIN BOOST_PP_VARIADIC_SIZE(BOOST_PP_ARRAY_ENUM(ARRAY_EMPTY)) == 1 END # endif @@ -115,6 +117,9 @@ BEGIN BOOST_PP_ARRAY_ELEM(22, BOOST_PP_ARRAY_INSERT(ARRAY_LARGE,22,1000)) == 100 BEGIN BOOST_PP_ARRAY_ELEM(26, BOOST_PP_ARRAY_INSERT(ARRAY_LARGE,22,1000)) == 25 END BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_INSERT(ARRAY_LARGE,22,1000)) == 34 END +BEGIN BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_INSERT(ARRAY_EMPTY,0,25)) == 25 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_INSERT(ARRAY_EMPTY,0,1000)) == 1 END + // pop_back BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_POP_BACK(ARRAY)) == 2 END @@ -172,3 +177,4 @@ BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_REVERSE(ARRAY_VERY_LARGE)) == 64 END BEGIN BOOST_PP_ARRAY_ELEM(0, BOOST_PP_ARRAY_REVERSE(ARRAY)) == 2 END BEGIN BOOST_PP_ARRAY_ELEM(29, BOOST_PP_ARRAY_REVERSE(ARRAY_LARGE)) == 3 END BEGIN BOOST_PP_ARRAY_ELEM(38, BOOST_PP_ARRAY_REVERSE(ARRAY_VERY_LARGE)) == 25 END +BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_ARRAY_REVERSE(ARRAY_EMPTY)) == 0 END diff --git a/test/list.cxx b/test/list.cxx index 1e33274..187787b 100644 --- a/test/list.cxx +++ b/test/list.cxx @@ -51,12 +51,16 @@ BEGIN BOOST_PP_VARIADIC_ELEM(2,BOOST_PP_LIST_ENUM(LIST)) == 5 END #endif BEGIN BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_SUB_D, 22, LIST) == 10 END +BEGIN BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_SUB_D, 22, LISTNIL) == 22 END BEGIN BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_ADD_D, 0, LIST) == 12 END +BEGIN BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_ADD_D, 0, LISTNIL) == 0 END BEGIN BOOST_PP_LIST_FOLD_RIGHT(REVERSAL, 0, LIST) == 4 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_REVERSE(LIST)) == 2514 END +BEGIN BOOST_PP_LIST_IS_NIL(BOOST_PP_LIST_REVERSE(LISTNIL)) == 1 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_REST_N(2, LIST)) == 52 END +BEGIN BOOST_PP_LIST_IS_NIL(BOOST_PP_LIST_REST_N(0, LISTNIL)) == 1 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FIRST_N(2, LIST)) == 41 END BEGIN BOOST_PP_LIST_AT(LIST, 2) == 5 END @@ -64,7 +68,11 @@ BEGIN BOOST_PP_LIST_SIZE(LIST) == 4 END BEGIN BOOST_PP_LIST_SIZE(LISTNIL) == 0 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D, 2, LIST)) == 6374 END +BEGIN BOOST_PP_LIST_IS_NIL(BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D, 2, LISTNIL)) == 1 END BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_APPEND(BOOST_PP_LIST_REST(LIST), LIST)) == 1524152 END +BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_APPEND(LIST,LISTNIL)) == 4152 END +BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_APPEND(LISTNIL,LIST)) == 4152 END +BEGIN BOOST_PP_LIST_IS_NIL(BOOST_PP_LIST_APPEND(LISTNIL,LISTNIL)) == 1 END BEGIN BOOST_PP_LIST_FOR_EACH(F1, 1, LIST) == 16 END BEGIN BOOST_PP_LIST_FOR_EACH_I(FI2, 1, LIST) == 17 END @@ -79,6 +87,7 @@ BEGIN BOOST_PP_TUPLE_SIZE(BOOST_PP_LIST_TO_TUPLE(LISTNIL)) == 1 END #endif BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D, 3, LIST)) == 45 END +BEGIN BOOST_PP_LIST_IS_NIL(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D, 3, LISTNIL)) == 1 END BEGIN BOOST_PP_LIST_FOR_EACH_PRODUCT(F2, 2, ( (1, (0, BOOST_PP_NIL)), (2, (3, BOOST_PP_NIL)) )) == 0 END From 1f16a481c72933af001f710343ff114f74aa498b Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 5 May 2014 20:49:20 -0400 Subject: [PATCH 13/19] Changed functionality so empty arrays/lists when converted to a seq or a tuple expand to nothing. --- include/boost/preprocessor/array/to_seq.hpp | 19 ++++++++++-- include/boost/preprocessor/array/to_tuple.hpp | 13 +++++++- include/boost/preprocessor/list/to_array.hpp | 14 +++++++++ include/boost/preprocessor/list/to_tuple.hpp | 30 ++++++++++++++++--- test/array.cxx | 5 ---- test/list.cxx | 8 ----- 6 files changed, 68 insertions(+), 21 deletions(-) diff --git a/include/boost/preprocessor/array/to_seq.hpp b/include/boost/preprocessor/array/to_seq.hpp index ebcae53..3534d9c 100644 --- a/include/boost/preprocessor/array/to_seq.hpp +++ b/include/boost/preprocessor/array/to_seq.hpp @@ -15,19 +15,32 @@ # # include # include +# include +# include +# include # include # # /* BOOST_PP_ARRAY_TO_SEQ */ # +# define BOOST_PP_ARRAY_TO_SEQ(array) \ + BOOST_PP_IF \ + ( \ + BOOST_PP_ARRAY_SIZE(array), \ + BOOST_PP_ARRAY_TO_SEQ_DO, \ + BOOST_PP_EMPTY \ + ) \ + (array) \ +/**/ +# # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() -# define BOOST_PP_ARRAY_TO_SEQ(array) BOOST_PP_ARRAY_TO_SEQ_I(BOOST_PP_TUPLE_TO_SEQ, array) +# define BOOST_PP_ARRAY_TO_SEQ_DO(array) BOOST_PP_ARRAY_TO_SEQ_I(BOOST_PP_TUPLE_TO_SEQ, array) # define BOOST_PP_ARRAY_TO_SEQ_I(m, args) BOOST_PP_ARRAY_TO_SEQ_II(m, args) # define BOOST_PP_ARRAY_TO_SEQ_II(m, args) BOOST_PP_CAT(m ## args,) # elif BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() -# define BOOST_PP_ARRAY_TO_SEQ(array) BOOST_PP_ARRAY_TO_SEQ_I(array) +# define BOOST_PP_ARRAY_TO_SEQ_DO(array) BOOST_PP_ARRAY_TO_SEQ_I(array) # define BOOST_PP_ARRAY_TO_SEQ_I(array) BOOST_PP_TUPLE_TO_SEQ ## array # else -# define BOOST_PP_ARRAY_TO_SEQ(array) BOOST_PP_TUPLE_TO_SEQ array +# define BOOST_PP_ARRAY_TO_SEQ_DO(array) BOOST_PP_TUPLE_TO_SEQ array # endif # # endif diff --git a/include/boost/preprocessor/array/to_tuple.hpp b/include/boost/preprocessor/array/to_tuple.hpp index eb83274..b513e22 100644 --- a/include/boost/preprocessor/array/to_tuple.hpp +++ b/include/boost/preprocessor/array/to_tuple.hpp @@ -14,9 +14,20 @@ # define BOOST_PREPROCESSOR_ARRAY_TO_TUPLE_HPP # # include +# include +# include +# include # # /* BOOST_PP_ARRAY_TO_TUPLE */ # -# define BOOST_PP_ARRAY_TO_TUPLE BOOST_PP_ARRAY_DATA +# define BOOST_PP_ARRAY_TO_TUPLE(array) \ + BOOST_PP_IF \ + ( \ + BOOST_PP_ARRAY_SIZE(array), \ + BOOST_PP_ARRAY_DATA, \ + BOOST_PP_EMPTY \ + ) \ + (array) \ +/**/ # # endif diff --git a/include/boost/preprocessor/list/to_array.hpp b/include/boost/preprocessor/list/to_array.hpp index 3711d4c..bd44d68 100644 --- a/include/boost/preprocessor/list/to_array.hpp +++ b/include/boost/preprocessor/list/to_array.hpp @@ -137,6 +137,20 @@ # # /* BOOST_PP_LIST_TO_ARRAY_D */ # +# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && (_MSC_VER <= 1400) +# define BOOST_PP_LIST_TO_ARRAY_D(d, list) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_LIST_IS_NIL(list), \ + BOOST_PP_LIST_TO_ARRAY_D_VC8ORLESS_EMPTY, \ + BOOST_PP_LIST_TO_ARRAY_D_VC8ORLESS_DO \ + ) \ + (d, list) \ +/**/ +# define BOOST_PP_LIST_TO_ARRAY_D_VC8ORLESS_EMPTY(d, list) (0,()) +# define BOOST_PP_LIST_TO_ARRAY_D_VC8ORLESS_DO(d, list) BOOST_PP_LIST_TO_ARRAY_I(BOOST_PP_WHILE_ ## d, list) +# else # define BOOST_PP_LIST_TO_ARRAY_D(d, list) BOOST_PP_LIST_TO_ARRAY_I(BOOST_PP_WHILE_ ## d, list) +# endif # # endif /* BOOST_PREPROCESSOR_LIST_TO_ARRAY_HPP */ diff --git a/include/boost/preprocessor/list/to_tuple.hpp b/include/boost/preprocessor/list/to_tuple.hpp index 557de36..d693b91 100644 --- a/include/boost/preprocessor/list/to_tuple.hpp +++ b/include/boost/preprocessor/list/to_tuple.hpp @@ -16,22 +16,44 @@ # # include # include +# include +# include # # /* BOOST_PP_LIST_TO_TUPLE */ # +# define BOOST_PP_LIST_TO_TUPLE(list) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_LIST_IS_NIL(list), \ + BOOST_PP_EMPTY, \ + BOOST_PP_LIST_TO_TUPLE_DO \ + ) \ + (list) \ +/**/ +# # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() -# define BOOST_PP_LIST_TO_TUPLE(list) (BOOST_PP_LIST_ENUM(list)) +# define BOOST_PP_LIST_TO_TUPLE_DO(list) (BOOST_PP_LIST_ENUM(list)) # else -# define BOOST_PP_LIST_TO_TUPLE(list) BOOST_PP_LIST_TO_TUPLE_I(list) +# define BOOST_PP_LIST_TO_TUPLE_DO(list) BOOST_PP_LIST_TO_TUPLE_I(list) # define BOOST_PP_LIST_TO_TUPLE_I(list) (BOOST_PP_LIST_ENUM(list)) # endif # # /* BOOST_PP_LIST_TO_TUPLE_R */ # +# define BOOST_PP_LIST_TO_TUPLE_R(r, list) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_LIST_IS_NIL(list), \ + BOOST_PP_EMPTY, \ + BOOST_PP_LIST_TO_TUPLE_R_DO \ + ) \ + (r, list) \ +/**/ +# # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() -# define BOOST_PP_LIST_TO_TUPLE_R(r, list) (BOOST_PP_LIST_ENUM_R(r, list)) +# define BOOST_PP_LIST_TO_TUPLE_R_DO(r, list) (BOOST_PP_LIST_ENUM_R(r, list)) # else -# define BOOST_PP_LIST_TO_TUPLE_R(r, list) BOOST_PP_LIST_TO_TUPLE_R_I(r, list) +# define BOOST_PP_LIST_TO_TUPLE_R_DO(r, list) BOOST_PP_LIST_TO_TUPLE_R_I(r, list) # define BOOST_PP_LIST_TO_TUPLE_R_I(r, list) (BOOST_PP_LIST_ENUM_R(r, list)) # endif # diff --git a/test/array.cxx b/test/array.cxx index 975aaa3..745581d 100644 --- a/test/array.cxx +++ b/test/array.cxx @@ -81,8 +81,6 @@ BEGIN BOOST_PP_SEQ_ELEM(0, BOOST_PP_ARRAY_TO_SEQ(ARRAY)) == 0 END BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_ARRAY_TO_SEQ((5, (0, 1, 2, 3, 4)))) == 3 END BEGIN BOOST_PP_SEQ_ELEM(17, BOOST_PP_ARRAY_TO_SEQ(ARRAY_LARGE)) == 17 END BEGIN BOOST_PP_SEQ_ELEM(42, BOOST_PP_ARRAY_TO_SEQ((64, (0, 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)))) == 42 END -BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_SEQ_ELEM(0,BOOST_PP_ARRAY_TO_SEQ(ARRAY_EMPTY))) == 1 END -BEGIN BOOST_PP_SEQ_SIZE(BOOST_PP_ARRAY_TO_SEQ(ARRAY_EMPTY)) == 1 END // to_tuple @@ -92,8 +90,6 @@ BEGIN BOOST_PP_TUPLE_ELEM(2, BOOST_PP_ARRAY_TO_TUPLE(ARRAY)) == 2 END BEGIN BOOST_PP_TUPLE_ELEM(1, BOOST_PP_ARRAY_TO_TUPLE((5, (0, 1, 2, 3, 4)))) == 1 END BEGIN BOOST_PP_TUPLE_ELEM(26, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_LARGE)) == 26 END BEGIN BOOST_PP_TUPLE_ELEM(37, BOOST_PP_ARRAY_TO_TUPLE((64, (0, 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)))) == 37 END -BEGIN BOOST_PP_TUPLE_SIZE(BOOST_PP_ARRAY_TO_TUPLE(ARRAY_EMPTY)) == 1 END -BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_EMPTY))) == 1 END # else @@ -101,7 +97,6 @@ BEGIN BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_ARRAY_TO_TUPLE(ARRAY)) == 2 END BEGIN BOOST_PP_TUPLE_ELEM(5, 1, BOOST_PP_ARRAY_TO_TUPLE((5, (0, 1, 2, 3, 4)))) == 1 END BEGIN BOOST_PP_TUPLE_ELEM(33, 26, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_LARGE)) == 26 END BEGIN BOOST_PP_TUPLE_ELEM(64, 37, BOOST_PP_ARRAY_TO_TUPLE((64, (0, 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)))) == 37 END -BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1, 0, BOOST_PP_ARRAY_TO_TUPLE(ARRAY_EMPTY))) == 1 END # endif diff --git a/test/list.cxx b/test/list.cxx index 187787b..7c99d70 100644 --- a/test/list.cxx +++ b/test/list.cxx @@ -78,13 +78,6 @@ BEGIN BOOST_PP_LIST_FOR_EACH(F1, 1, LIST) == 16 END BEGIN BOOST_PP_LIST_FOR_EACH_I(FI2, 1, LIST) == 17 END BEGIN BOOST_PP_TUPLE_ELEM(4, 3, BOOST_PP_LIST_TO_TUPLE(LIST)) == 2 END -BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_TUPLE_ELEM(1, 0, BOOST_PP_LIST_TO_TUPLE(LISTNIL))) == 1 END - -#if BOOST_PP_VARIADICS - -BEGIN BOOST_PP_TUPLE_SIZE(BOOST_PP_LIST_TO_TUPLE(LISTNIL)) == 1 END - -#endif BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D, 3, LIST)) == 45 END BEGIN BOOST_PP_LIST_IS_NIL(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D, 3, LISTNIL)) == 1 END @@ -96,4 +89,3 @@ BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_APPEND_D, BOOST_PP BEGIN BOOST_PP_ARRAY_ELEM(2, BOOST_PP_LIST_TO_ARRAY(LIST)) == 5 END BEGIN BOOST_PP_ARRAY_SIZE(BOOST_PP_LIST_TO_ARRAY(LISTNIL)) == 0 END BEGIN BOOST_PP_SEQ_ELEM(3, BOOST_PP_LIST_TO_SEQ(LIST)) == 2 END -BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_LIST_TO_SEQ(LISTNIL)) == 1 END From 9d308c1b9d8d9018e1fd460b581155cd59acbdc2 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Fri, 23 May 2014 10:23:40 -0400 Subject: [PATCH 14/19] Changed BOOST_PP_EMPTY to only use the variadic version when not VC++. Corrected others to use local version of EMPTY. --- include/boost/preprocessor/array/to_seq.hpp | 4 ++-- include/boost/preprocessor/array/to_tuple.hpp | 4 ++-- include/boost/preprocessor/facilities/empty.hpp | 6 +++++- .../boost/preprocessor/facilities/is_empty_variadic.hpp | 7 ++++--- include/boost/preprocessor/list/to_tuple.hpp | 7 ++++--- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/boost/preprocessor/array/to_seq.hpp b/include/boost/preprocessor/array/to_seq.hpp index 3534d9c..7303f34 100644 --- a/include/boost/preprocessor/array/to_seq.hpp +++ b/include/boost/preprocessor/array/to_seq.hpp @@ -17,7 +17,6 @@ # include # include # include -# include # include # # /* BOOST_PP_ARRAY_TO_SEQ */ @@ -27,10 +26,11 @@ ( \ BOOST_PP_ARRAY_SIZE(array), \ BOOST_PP_ARRAY_TO_SEQ_DO, \ - BOOST_PP_EMPTY \ + BOOST_PP_ARRAY_TO_SEQ_EMPTY \ ) \ (array) \ /**/ +# define BOOST_PP_ARRAY_TO_SEQ_EMPTY(array) # # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() # define BOOST_PP_ARRAY_TO_SEQ_DO(array) BOOST_PP_ARRAY_TO_SEQ_I(BOOST_PP_TUPLE_TO_SEQ, array) diff --git a/include/boost/preprocessor/array/to_tuple.hpp b/include/boost/preprocessor/array/to_tuple.hpp index b513e22..0d8defa 100644 --- a/include/boost/preprocessor/array/to_tuple.hpp +++ b/include/boost/preprocessor/array/to_tuple.hpp @@ -16,7 +16,6 @@ # include # include # include -# include # # /* BOOST_PP_ARRAY_TO_TUPLE */ # @@ -25,9 +24,10 @@ ( \ BOOST_PP_ARRAY_SIZE(array), \ BOOST_PP_ARRAY_DATA, \ - BOOST_PP_EMPTY \ + BOOST_PP_ARRAY_TO_TUPLE_EMPTY \ ) \ (array) \ /**/ +# define BOOST_PP_ARRAY_TO_TUPLE_EMPTY(array) # # endif diff --git a/include/boost/preprocessor/facilities/empty.hpp b/include/boost/preprocessor/facilities/empty.hpp index 99e1daa..0829a13 100644 --- a/include/boost/preprocessor/facilities/empty.hpp +++ b/include/boost/preprocessor/facilities/empty.hpp @@ -19,10 +19,14 @@ # # /* BOOST_PP_EMPTY */ # -# if BOOST_PP_VARIADICS +# if BOOST_PP_VARIADICS && !BOOST_PP_VARIADICS_MSVC # define BOOST_PP_EMPTY(...) # else # define BOOST_PP_EMPTY() # endif # +# if BOOST_PP_VARIADICS +# define BOOST_PP_VARIADIC_EMPTY(...) +# endif +# # endif diff --git a/include/boost/preprocessor/facilities/is_empty_variadic.hpp b/include/boost/preprocessor/facilities/is_empty_variadic.hpp index c2700fe..eee4062 100644 --- a/include/boost/preprocessor/facilities/is_empty_variadic.hpp +++ b/include/boost/preprocessor/facilities/is_empty_variadic.hpp @@ -16,7 +16,6 @@ # # if BOOST_PP_VARIADICS # -# include # include # include # @@ -31,11 +30,12 @@ ) \ ) \ ( \ - 0 BOOST_PP_EMPTY, \ + BOOST_PP_IS_EMPTY_ZERO, \ BOOST_PP_DETAIL_IS_EMPTY_PROCESS \ ) \ (param) \ /**/ +#define BOOST_PP_IS_EMPTY_ZERO(param) 0 # else #define BOOST_PP_IS_EMPTY(...) \ BOOST_PP_DETAIL_IS_EMPTY_IIF \ @@ -46,11 +46,12 @@ ) \ ) \ ( \ - 0 BOOST_PP_EMPTY, \ + BOOST_PP_IS_EMPTY_ZERO, \ BOOST_PP_DETAIL_IS_EMPTY_PROCESS \ ) \ (__VA_ARGS__) \ /**/ +#define BOOST_PP_IS_EMPTY_ZERO(...) 0 # endif /* BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 */ # endif /* BOOST_PP_VARIADICS */ # endif /* BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP */ diff --git a/include/boost/preprocessor/list/to_tuple.hpp b/include/boost/preprocessor/list/to_tuple.hpp index d693b91..c7b3da8 100644 --- a/include/boost/preprocessor/list/to_tuple.hpp +++ b/include/boost/preprocessor/list/to_tuple.hpp @@ -17,7 +17,6 @@ # include # include # include -# include # # /* BOOST_PP_LIST_TO_TUPLE */ # @@ -25,11 +24,12 @@ BOOST_PP_IIF \ ( \ BOOST_PP_LIST_IS_NIL(list), \ - BOOST_PP_EMPTY, \ + BOOST_PP_LIST_TO_TUPLE_EMPTY, \ BOOST_PP_LIST_TO_TUPLE_DO \ ) \ (list) \ /**/ +# define BOOST_PP_LIST_TO_TUPLE_EMPTY(list) # # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() # define BOOST_PP_LIST_TO_TUPLE_DO(list) (BOOST_PP_LIST_ENUM(list)) @@ -44,11 +44,12 @@ BOOST_PP_IIF \ ( \ BOOST_PP_LIST_IS_NIL(list), \ - BOOST_PP_EMPTY, \ + BOOST_PP_LIST_TO_TUPLE_R_EMPTY, \ BOOST_PP_LIST_TO_TUPLE_R_DO \ ) \ (r, list) \ /**/ +# define BOOST_PP_LIST_TO_TUPLE_R_EMPTY(r,list) # # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() # define BOOST_PP_LIST_TO_TUPLE_R_DO(r, list) (BOOST_PP_LIST_ENUM_R(r, list)) From b03d46129c3bcaa898780d9938625c79d009f4e2 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sun, 25 May 2014 07:53:44 -0400 Subject: [PATCH 15/19] Change back to original implementation. --- include/boost/preprocessor/facilities/empty.hpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/boost/preprocessor/facilities/empty.hpp b/include/boost/preprocessor/facilities/empty.hpp index 0829a13..6f215dc 100644 --- a/include/boost/preprocessor/facilities/empty.hpp +++ b/include/boost/preprocessor/facilities/empty.hpp @@ -8,7 +8,6 @@ # */ # # /* Revised by Paul Mensonides (2002) */ -# /* Revised by Edward Diener (2014) */ # # /* See http://www.boost.org for most recent version. */ # @@ -19,14 +18,6 @@ # # /* BOOST_PP_EMPTY */ # -# if BOOST_PP_VARIADICS && !BOOST_PP_VARIADICS_MSVC -# define BOOST_PP_EMPTY(...) -# else # define BOOST_PP_EMPTY() -# endif -# -# if BOOST_PP_VARIADICS -# define BOOST_PP_VARIADIC_EMPTY(...) -# endif # # endif From 70e0f2d6e0e3577c5783cda08f84f6f8319ca070 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 26 May 2014 16:36:30 -0400 Subject: [PATCH 16/19] Using BOOST_PP_IDENTITY makes code clearer. --- include/boost/preprocessor/facilities/is_empty.hpp | 4 ++-- include/boost/preprocessor/facilities/is_empty_or_1.hpp | 3 ++- include/boost/preprocessor/seq/rest_n.hpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/boost/preprocessor/facilities/is_empty.hpp b/include/boost/preprocessor/facilities/is_empty.hpp index e7f821f..d0403a9 100644 --- a/include/boost/preprocessor/facilities/is_empty.hpp +++ b/include/boost/preprocessor/facilities/is_empty.hpp @@ -24,7 +24,7 @@ # include # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() # include -# include +# include # else # include # include @@ -35,7 +35,7 @@ # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() # define BOOST_PP_IS_EMPTY(x) BOOST_PP_IS_EMPTY_I(x BOOST_PP_IS_EMPTY_HELPER) # define BOOST_PP_IS_EMPTY_I(contents) BOOST_PP_TUPLE_ELEM(2, 1, (BOOST_PP_IS_EMPTY_DEF_ ## contents())) -# define BOOST_PP_IS_EMPTY_DEF_BOOST_PP_IS_EMPTY_HELPER 1, 1 BOOST_PP_EMPTY +# define BOOST_PP_IS_EMPTY_DEF_BOOST_PP_IS_EMPTY_HELPER 1, BOOST_PP_IDENTITY(1) # define BOOST_PP_IS_EMPTY_HELPER() , 0 # else # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() diff --git a/include/boost/preprocessor/facilities/is_empty_or_1.hpp b/include/boost/preprocessor/facilities/is_empty_or_1.hpp index baa5da9..815666f 100644 --- a/include/boost/preprocessor/facilities/is_empty_or_1.hpp +++ b/include/boost/preprocessor/facilities/is_empty_or_1.hpp @@ -14,6 +14,7 @@ # # include # include +# include # include # include # @@ -22,7 +23,7 @@ # define BOOST_PP_IS_EMPTY_OR_1(x) \ BOOST_PP_IIF( \ BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()), \ - 1 BOOST_PP_EMPTY, \ + BOOST_PP_IDENTITY(1), \ BOOST_PP_IS_1 \ )(x) \ /**/ diff --git a/include/boost/preprocessor/seq/rest_n.hpp b/include/boost/preprocessor/seq/rest_n.hpp index 7e589cc..6423376 100644 --- a/include/boost/preprocessor/seq/rest_n.hpp +++ b/include/boost/preprocessor/seq/rest_n.hpp @@ -14,17 +14,17 @@ # # include # include -# include +# include # include # include # # /* 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), (nil) seq BOOST_PP_EMPTY))() +# 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 )))() # 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), (nil) seq BOOST_PP_EMPTY))() +# 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 )))() # endif # # endif From e57370608eec0a6da06c30ef3dfbd2b5bf10152c Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Wed, 4 Jun 2014 06:50:33 -0400 Subject: [PATCH 17/19] Updated doc for empty array and/or list when converted to other data type. --- doc/ref/array_to_list.html | 70 +++++++++++++----------- doc/ref/array_to_seq.html | 64 ++++++++++++---------- doc/ref/array_to_tuple.html | 66 ++++++++++++---------- doc/ref/list_to_array.html | 82 +++++++++++++++------------- doc/ref/list_to_array_d.html | 57 ++++++++++--------- doc/ref/list_to_seq.html | 80 ++++++++++++++------------- doc/ref/list_to_seq_r.html | 55 ++++++++++--------- doc/ref/list_to_tuple.html | 103 ++++++++++++++++------------------- doc/ref/list_to_tuple_r.html | 103 ++++++++++++++++------------------- 9 files changed, 356 insertions(+), 324 deletions(-) diff --git a/doc/ref/array_to_list.html b/doc/ref/array_to_list.html index 607b205..8ea7133 100644 --- a/doc/ref/array_to_list.html +++ b/doc/ref/array_to_list.html @@ -1,33 +1,41 @@ - - BOOST_PP_ARRAY_TO_LIST - - - -
The BOOST_PP_ARRAY_TO_LIST -macro converts an array to a list.
-

Usage

-
BOOST_PP_ARRAY_TO_LIST(array) -
-

Arguments

-
array
-
The array to be converted.
-
-
    -
-

Requirements

- -

Sample Code

-
-
#include <boost/preprocessor/array/to_list.hpp>

BOOST_PP_ARRAY_TO_LIST((3, (x, y, z)))
// expands to (x, (y, (z, BOOST_PP_NIL)))
-
-
-
© Copyright Edward Diener 2011
-
-

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)

-
- + + + BOOST_PP_ARRAY_TO_LIST + + + +
The BOOST_PP_ARRAY_TO_LIST macro + converts an array to a list.
+

Usage

+
BOOST_PP_ARRAY_TO_LIST(array)
+

Arguments

+
+
array
+
The array to be converted.
+
+
    +
+

Remarks

+

    If the array to be converted is empty, as + represented by '( 0, () )', the resulting list is empty, as + represented by 'BOOST_PP_NIL'.

+

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/array/to_list.hpp>

BOOST_PP_ARRAY_TO_LIST((3, (x, y, z)))
// expands to (x, (y, (z, BOOST_PP_NIL)))
+
+
+
© Copyright Edward Diener 2011
+
+

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)

+
+ s + diff --git a/doc/ref/array_to_seq.html b/doc/ref/array_to_seq.html index 308b364..7140176 100644 --- a/doc/ref/array_to_seq.html +++ b/doc/ref/array_to_seq.html @@ -1,31 +1,37 @@ - - BOOST_PP_ARRAY_TO_SEQ - - - -
The BOOST_PP_ARRAY_TO_SEQ macro -converts an array to a seq.
-

Usage

-
BOOST_PP_ARRAY_TO_SEQ(array) -
-

Arguments

-
array
-
The array to be converted.
-
-

Requirements

- -

Sample Code

-
-
#include <boost/preprocessor/array/to_seq.hpp>

BOOST_PP_ARRAY_TO_SEQ((3, (a, b, c))) // expands to (a)(b)(c)
-
-
-
© Copyright Edward Diener 2011
-
-

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)

-
- + + + BOOST_PP_ARRAY_TO_SEQ + + + +
The BOOST_PP_ARRAY_TO_SEQ macro + converts an array to a seq.
+

Usage

+
BOOST_PP_ARRAY_TO_SEQ(array)
+

Arguments

+
+
array
+
The array to be converted.
+
+

Remarks

+

    If the array to be converted is empty, as + represented by '( 0, () )', the resulting seq is undefined since a + seq cannot be empty.

+

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/array/to_seq.hpp>

BOOST_PP_ARRAY_TO_SEQ((3, (a, b, c))) // expands to (a)(b)(c)
+
+
+
© Copyright Edward Diener 2011
+
+

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)

+
+ diff --git a/doc/ref/array_to_tuple.html b/doc/ref/array_to_tuple.html index 085dd39..8f9c958 100644 --- a/doc/ref/array_to_tuple.html +++ b/doc/ref/array_to_tuple.html @@ -1,31 +1,39 @@ - - BOOST_PP_ARRAY_TO_TUPLE - - - -
The BOOST_PP_ARRAY_TO_TUPLE macro -converts an array to an tuple.
-

Usage

-
BOOST_PP_ARRAY_TO_TUPLE(array)
-

Arguments

-
-
array
-
The array to be converted.
-
-

Requirements

- -

Sample Code

-
-
#include <boost/preprocessor/array/to_tuple.hpp>

#define ARRAY (3,(a, b, c))

BOOST_PP_ARRAY_TO_TUPLE(ARRAY) // expands to (a, b, c)
-
-
-
© Copyright Edward Diener 2011
-
-

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)

-
- + + + BOOST_PP_ARRAY_TO_TUPLE + + + +
The BOOST_PP_ARRAY_TO_TUPLE macro + converts an array to an tuple.
+

Usage

+
BOOST_PP_ARRAY_TO_TUPLE(array)
+

Arguments

+
+
array
+
The array to be converted.
+
+

Remarks

+

    If the array to be converted is empty, as + represented by '( 0, () )', the resulting tuple is undefined + since a tuple cannot be empty.

+

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/array/to_tuple.hpp>

#define ARRAY (3,(a, b, c))

BOOST_PP_ARRAY_TO_TUPLE(ARRAY) // expands to (a, b, c)
+
+
+
© Copyright Edward Diener 2011 +
+
+

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)

+
+ diff --git a/doc/ref/list_to_array.html b/doc/ref/list_to_array.html index b691b34..46154c9 100644 --- a/doc/ref/list_to_array.html +++ b/doc/ref/list_to_array.html @@ -1,39 +1,47 @@ - - BOOST_PP_LIST_TO_ARRAY - - -
The BOOST_PP_LIST_TO_ARRAY macro -converts a list to an array.
-

Usage

-
BOOST_PP_LIST_TO_ARRAY(list)
-

Arguments

-
-
list
-
The list to be converted.
-
-

Remarks

-
- This macro uses BOOST_PP_WHILE. - Within BOOST_PP_WHILE, it is more efficient to use BOOST_PP_LIST_TO_ARRAY_D. -
-

See Also

- -

Requirements

- -

Sample Code

-
-
#include <boost/preprocessor/list/to_array.hpp>

#define LIST (a, (b, (c, BOOST_PP_NIL)))

BOOST_PP_LIST_TO_ARRAY(LIST) // expands to (3, (a, b, c))
-
-
-
© Copyright Edward Diener 2011
-
-

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)

-
- + + + BOOST_PP_LIST_TO_ARRAY + + + +
The BOOST_PP_LIST_TO_ARRAY macro + converts a list to an array.
+

Usage

+
BOOST_PP_LIST_TO_ARRAY(list)
+

Arguments

+
+
list
+
The list to be converted.
+
+
+

Remarks

+
This macro uses BOOST_PP_WHILE. Within BOOST_PP_WHILE, + it is more efficient to use BOOST_PP_LIST_TO_ARRAY_D.
+
+ If the list to be converted is empty, as represented by + 'BOOST_PP_NIL', the resulting array is empty, as represented by '( 0, () + )'.
+

See Also

+ +

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/list/to_array.hpp>

#define LIST (a, (b, (c, BOOST_PP_NIL)))

BOOST_PP_LIST_TO_ARRAY(LIST) // expands to (3, (a, b, c))
+
+
+
© Copyright Edward Diener 2011 +
+
+

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)

+
+ diff --git a/doc/ref/list_to_array_d.html b/doc/ref/list_to_array_d.html index 8d93328..835d9e2 100644 --- a/doc/ref/list_to_array_d.html +++ b/doc/ref/list_to_array_d.html @@ -1,27 +1,34 @@ - - BOOST_PP_LIST_TO_ARRAY_D - - -
-The BOOST_PP_LIST_TO_ARRAY_D macro converts a list to an array. -It reenters BOOST_PP_WHILE with maximum efficiency. -
-

Usage

-
BOOST_PP_LIST_TO_ARRAY_D(d, list)
-

Arguments

-
-
d
-
The next available BOOST_PP_WHILE iteration.
-
list
-
The list to be converted.
-
-

See Also

- -

Requirements

- - + + + BOOST_PP_LIST_TO_ARRAY_D + + + +
The BOOST_PP_LIST_TO_ARRAY_D macro + converts a list to an array. It reenters BOOST_PP_WHILE + with maximum efficiency.
+

Usage

+
BOOST_PP_LIST_TO_ARRAY_D(d, list) +
+

Arguments

+
+
d
+
The next available BOOST_PP_WHILE iteration.
+
list
+
The list to be converted.
+
+

Remarks

+

    If the list to be converted is empty, as + represented by 'BOOST_PP_NIL', the resulting array is empty, as + represented by '( 0, () )'.

+

See Also

+

See Also

+ +

Requirements

+ + diff --git a/doc/ref/list_to_seq.html b/doc/ref/list_to_seq.html index 2f77cf1..b023546 100644 --- a/doc/ref/list_to_seq.html +++ b/doc/ref/list_to_seq.html @@ -1,40 +1,44 @@ - - BOOST_PP_LIST_TO_SEQ - - - -
The BOOST_PP_LIST_TO_SEQ macro -converts a list to a seq.
-

Usage

-
BOOST_PP_LIST_TO_SEQ(list) -
-

Arguments

-
list
-
The list to be converted.
-
-

Remarks

-
- This macro uses BOOST_PP_FOR. - Within BOOST_PP_FOR, it is more efficient to use BOOST_PP_LIST_TO_SEQ_R. -
-

See Also

- -

Requirements

- -

Sample Code

-
-
#include <boost/preprocessor/list/to_seq.hpp>

BOOST_PP_LIST_TO_SEQ((a, (b, (c, BOOST_PP_NIL)))) // expands to (a)(b)(c)
-
-
-
© Copyright Edward Diener 2011
-
-

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)

-
- + + + BOOST_PP_LIST_TO_SEQ + + + +
The BOOST_PP_LIST_TO_SEQ macro + converts a list to a seq.
+

Usage

+
BOOST_PP_LIST_TO_SEQ(list)
+

Arguments

+
+
list
+
The list to be converted.
+
+

Remarks

+
This macro uses BOOST_PP_FOR. Within BOOST_PP_FOR, it + is more efficient to use BOOST_PP_LIST_TO_SEQ_R.
+
+ If the list to be converted is empty, as represented by + 'BOOST_PP_NIL', the resulting seq is undefined since a seq + cannot be empty.
+

See Also

+ +

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/list/to_seq.hpp>

BOOST_PP_LIST_TO_SEQ((a, (b, (c, BOOST_PP_NIL)))) // expands to (a)(b)(c)
+
+
+
© Copyright Edward Diener 2011
+
+

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)

+
+ diff --git a/doc/ref/list_to_seq_r.html b/doc/ref/list_to_seq_r.html index 2c2bb37..cc7a854 100644 --- a/doc/ref/list_to_seq_r.html +++ b/doc/ref/list_to_seq_r.html @@ -1,27 +1,32 @@ - - BOOST_PP_LIST_TO_SEQ_R - - -
-The BOOST_PP_LIST_TO_SEQ_R macro converts a list to an seq. -It reenters BOOST_PP_FOR with maximum efficiency. -
-

Usage

-
BOOST_PP_LIST_TO_SEQ_R(r, list)
-

Arguments

-
-
d
-
The next available BOOST_PP_FOR repetition.
-
list
-
The list to be converted.
-
-

See Also

- -

Requirements

- - + + + BOOST_PP_LIST_TO_SEQ_R + + + +
The BOOST_PP_LIST_TO_SEQ_R macro + converts a list to a seq. It reenters BOOST_PP_FOR + with maximum efficiency.
+

Usage

+
BOOST_PP_LIST_TO_SEQ_R(r, list)
+

Arguments

+
+
d
+
The next available BOOST_PP_FOR repetition.
+
list
+
The list to be converted.
+
+

Remarks

+

    If the list to be converted is empty, as + represented by 'BOOST_PP_NIL', the resulting seq is undefined + since a seq cannot be empty.

+

See Also

+ +

Requirements

+ + diff --git a/doc/ref/list_to_tuple.html b/doc/ref/list_to_tuple.html index 37e7311..d022c2b 100644 --- a/doc/ref/list_to_tuple.html +++ b/doc/ref/list_to_tuple.html @@ -1,62 +1,55 @@ - - BOOST_PP_LIST_TO_TUPLE - - - -
- The BOOST_PP_LIST_TO_TUPLE macro converts a list to a tuple. -
-

Usage

-
- BOOST_PP_LIST_TO_TUPLE(list) -
-

Arguments

-
-
list
-
- The list to be converted. -
-
-

Remarks

-
- If list is, for example, (a, (b, (c, BOOST_PP_NIL))), - this macro will produce: -
- (a, b, c) -
-
-
- Previously, this macro could not be used inside BOOST_PP_FOR.  - There is no longer any such restriction.  - It is more efficient, however, to use BOOST_PP_LIST_TO_TUPLE_R in such a situation. -
-

See Also

- -

Requirements

- -

Sample Code

-
-#include <boost/preprocessor/list/to_tuple.hpp>
+  
+    
+    BOOST_PP_LIST_TO_TUPLE
+    
+  
+  
+    
The BOOST_PP_LIST_TO_TUPLE macro + converts a list to a tuple.
+

Usage

+
BOOST_PP_LIST_TO_TUPLE(list)
+

Arguments

+
+
list
+
The list to be converted.
+
+

Remarks

+
If list is, for example, (a, (b, (c, BOOST_PP_NIL))), + this macro will produce: +
(a, b, c)
+
+
Previously, this macro could not be used inside BOOST_PP_FOR.  + There is no longer any such restriction.  It is more efficient, + however, to use BOOST_PP_LIST_TO_TUPLE_R in such a situation.
+
+ If the list to be converted is empty, as represented by 'BOOST_PP_NIL', + the resulting tuple is undefined since a tuple cannot be + empty.
+

See Also

+ +

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/list/to_tuple.hpp>
 
 #define LIST (w, (x, (y, (z, BOOST_PP_NIL))))
 
 BOOST_PP_LIST_TO_TUPLE(LIST) // expands to (w, x, y, z)
 
-
-
- © Copyright Housemarque Oy 2002 -
© Copyright Paul Mensonides 2002 -
-
-

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)

-
- +
+
© Copyright Housemarque Oy 2002
+ © Copyright Paul Mensonides 2002
+
+

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)

+
+ diff --git a/doc/ref/list_to_tuple_r.html b/doc/ref/list_to_tuple_r.html index 1ba51a0..a72c4de 100644 --- a/doc/ref/list_to_tuple_r.html +++ b/doc/ref/list_to_tuple_r.html @@ -1,47 +1,42 @@ - - BOOST_PP_LIST_TO_TUPLE_R - - - -
- The BOOST_PP_LIST_TO_TUPLE_R macro converts a list to a tuple.  - It reenters BOOST_PP_FOR with maximum efficiency. -
-

Usage

-
- BOOST_PP_LIST_TO_TUPLE_R(r, list) -
-

Arguments

-
-
r
-
- The next available BOOST_PP_FOR repetition. -
-
list
-
- The list to be converted. -
-
-

Remarks

-
- If list is, for example, (a, (b, (c, BOOST_PP_NIL))), - this macro will produce: -
- (a, b, c) -
-
-

See Also

- -

Requirements

- -

Sample Code

-
-#include <boost/preprocessor/list/adt.hpp>
+  
+    
+    BOOST_PP_LIST_TO_TUPLE_R
+    
+  
+  
+    
The BOOST_PP_LIST_TO_TUPLE_R macro + converts a list to a tuple.  It reenters BOOST_PP_FOR + with maximum efficiency.
+

Usage

+
BOOST_PP_LIST_TO_TUPLE_R(r, list) +
+

Arguments

+
+
r
+
The next available BOOST_PP_FOR repetition.
+
list
+
The list to be converted.
+
+

Remarks

+

   If list is, for example, (a, (b, (c, + BOOST_PP_NIL))), this macro will produce:

+
+
(a, b, c)  
+
+

   If the list to + be converted is empty, as represented by 'BOOST_PP_NIL', the resulting tuple + is undefined since a tuple cannot be empty.

+

See Also

+ +

Requirements

+ +

Sample Code

+
+
#include <boost/preprocessor/list/adt.hpp>
 #include <boost/preprocessor/list/to_tuple.hpp>
 #include <boost/preprocessor/repetition/for.hpp>
 
@@ -54,16 +49,14 @@
 BOOST_PP_FOR(LIST, PRED, OP, MACRO)
    // expands to (x, y, z) (y, z) (z)
 
-
-
- © Copyright Housemarque Oy 2002 -
© Copyright Paul Mensonides 2002 -
-
-

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)

-
- +
+
© Copyright Housemarque Oy 2002
+ © Copyright Paul Mensonides 2002
+
+

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)

+
+ From b43a4708eb48375115fcf04d21c092cd4710265d Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Wed, 4 Jun 2014 19:38:09 -0400 Subject: [PATCH 18/19] Correct line endings. --- doc/ref/array_to_list.html | 4 ++-- doc/ref/array_to_seq.html | 2 +- doc/ref/list_to_seq.html | 2 +- doc/ref/list_to_tuple_r.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/ref/array_to_list.html b/doc/ref/array_to_list.html index 8ea7133..2fdd247 100644 --- a/doc/ref/array_to_list.html +++ b/doc/ref/array_to_list.html @@ -25,8 +25,8 @@

Sample Code

-
#include <boost/preprocessor/array/to_list.hpp>

BOOST_PP_ARRAY_TO_LIST((3, (x, y, z)))
// expands to (x, (y, (z, #include <boost/preprocessor/array/to_list.hpp>

BOOST_PP_ARRAY_TO_LIST((3, (x, y, z)))
// expands to (x, (y, (z, BOOST_PP_NIL)))

diff --git a/doc/ref/array_to_seq.html b/doc/ref/array_to_seq.html index 7140176..bf3518e 100644 --- a/doc/ref/array_to_seq.html +++ b/doc/ref/array_to_seq.html @@ -23,7 +23,7 @@

Sample Code


diff --git a/doc/ref/list_to_seq.html b/doc/ref/list_to_seq.html index b023546..3efc7e1 100644 --- a/doc/ref/list_to_seq.html +++ b/doc/ref/list_to_seq.html @@ -30,7 +30,7 @@

Sample Code


diff --git a/doc/ref/list_to_tuple_r.html b/doc/ref/list_to_tuple_r.html index a72c4de..0227d38 100644 --- a/doc/ref/list_to_tuple_r.html +++ b/doc/ref/list_to_tuple_r.html @@ -50,7 +50,7 @@ // expands to (x, y, z) (y, z) (z)
-
© Copyright © Copyright Housemarque Oy 2002
© Copyright Paul Mensonides 2002
From 3f75659921c3a4bb635c986d2882fa0da324446a Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sun, 8 Jun 2014 02:00:24 -0400 Subject: [PATCH 19/19] Added documentation for is_begin_parens and remove_parens. --- doc/headers.html | 2 + doc/headers/punctuation/is_begin_parens.html | 26 +++++++++++ doc/headers/punctuation/remove_parens.html | 26 +++++++++++ doc/ref.html | 2 + doc/ref/is_begin_parens.html | 47 ++++++++++++++++++++ doc/ref/remove_parens.html | 44 ++++++++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 doc/headers/punctuation/is_begin_parens.html create mode 100644 doc/headers/punctuation/remove_parens.html create mode 100644 doc/ref/is_begin_parens.html create mode 100644 doc/ref/remove_parens.html diff --git a/doc/headers.html b/doc/headers.html index 90b59fd..e96b25e 100644 --- a/doc/headers.html +++ b/doc/headers.html @@ -138,8 +138,10 @@
  • punctuation/
  • comma.hpp
  • comma_if.hpp
  • +
  • is_begin_parens.hpp (v)
  • paren.hpp
  • paren_if.hpp
  • +
  • remove_parens.hpp (v)
  • repeat.hpp*
  • repeat_2nd.hpp*
  • repeat_3rd.hpp*
  • diff --git a/doc/headers/punctuation/is_begin_parens.html b/doc/headers/punctuation/is_begin_parens.html new file mode 100644 index 0000000..4897623 --- /dev/null +++ b/doc/headers/punctuation/is_begin_parens.html @@ -0,0 +1,26 @@ + + + + punctuation/is_begin_parens.hpp + + + +
    The punctuation/is_begin_parens.hpp + header defines a macro that determines if variadic data begins with a + parenthesis.
    +

    Usage

    +
    #include <boost/preprocessor/punctuation/is_begin_parens.hpp> +
    +

    Contents

    + +
    +
    © Copyright Edward Diener 2014
    +
    +

    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)

    +
    + + diff --git a/doc/headers/punctuation/remove_parens.html b/doc/headers/punctuation/remove_parens.html new file mode 100644 index 0000000..f2b6e46 --- /dev/null +++ b/doc/headers/punctuation/remove_parens.html @@ -0,0 +1,26 @@ + + + + punctuation/remove_parens.hpp + + + +
    The punctuation/remove_parens.hpp + header defines a macro that removes the beginning parenthesis from its + input if it exists.
    +

    Usage

    +
    #include <boost/preprocessor/punctuation/remove_parens.hpp> +
    +

    Contents

    + +
    +
    © Copyright Edward Diener 2014
    +
    +

    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)

    +
    + + diff --git a/doc/ref.html b/doc/ref.html index 82c2905..4d2081f 100644 --- a/doc/ref.html +++ b/doc/ref.html @@ -105,6 +105,7 @@
  • INCLUDE_SELF
  • INDIRECT_SELF
  • INTERCEPT
  • +
  • IS_BEGIN_PARENS (v)
  • IS_ITERATING
  • IS_SELFISH
  • ITERATE
  • @@ -209,6 +210,7 @@
  • RELATIVE_FLAGS
  • RELATIVE_ITERATION
  • RELATIVE_START
  • +
  • REMOVE_PARENS (v)
  • REPEAT
  • REPEAT_1ST*
  • REPEAT_2ND*
  • diff --git a/doc/ref/is_begin_parens.html b/doc/ref/is_begin_parens.html new file mode 100644 index 0000000..0e0b39c --- /dev/null +++ b/doc/ref/is_begin_parens.html @@ -0,0 +1,47 @@ + + + + BOOST_PP_IS_BEGIN_PARENS + + + +
    The BOOST_PP_IS_BEGIN_PARENS + determines whether the input starts with a set of parenthesis.
    +

    Usage

    +
    BOOST_PP_IS_BEGIN_PARENS(...) (v)
    +

    Arguments

    +

        ...        +     The input as variadic data.

    +

    Remarks

    +
    If the input input begins with a parenthesis, with any data within + that parenthesis, the macro returns 1, otherwise it returns 0. Data may + follow the beginning parenthesis and the macro still will return 1.
    +
    + For Visual Studio 2005 ( VC8 ) the input data must be a single parameter + else a compilation error will occur.
    +

    See Also

    + +

    Requirements

    + +

    Sample Code

    +
    +
    #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
    +
    +#define VARDATA more_data , more_params
    #define VARDATAP ( data ) more_data , more_params
    #define DATA data
    #define DATAP ( data ) more_data
    +BOOST_PP_IS_BEGIN_PARENS(VARDATA) // expands to 0, compiler error with VC8 +BOOST_PP_IS_BEGIN_PARENS(VARDATAP) // expands to 1, compiler error with VC8

    BOOST_PP_IS_BEGIN_PARENS(DATA) // expands to 0 +BOOST_PP_IS_BEGIN_PARENS(DATAP) // expands to 1

    BOOST_PP_IS_BEGIN_PARENS() // expands to 0
    +
    +
    +
    © Copyright Edward Diener 2014
    +
    +

    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)

    +
    + + diff --git a/doc/ref/remove_parens.html b/doc/ref/remove_parens.html new file mode 100644 index 0000000..72312dd --- /dev/null +++ b/doc/ref/remove_parens.html @@ -0,0 +1,44 @@ + + + + BOOST_PP_REMOVE_PARENS + + + +
    The BOOST_PP_REMOVE_PARENS macro + removes the beginning parenthesis, if it exists, from the input data and + expands to the result
    +

    Usage

    +
    BOOST_PP_REMOVE_PARENS(param) (v)
    +

    Arguments    

    +

        param   +         + The input data.

    +

    Remarks

    +
    If the input begins with a parenthesis, with any data within that + parenthesis, the macro removes the parenthesis and expands to the result. + If the input does not begin with a parenthesis the macro expands to the + input.
    +
    +

    See Also

    + +

    Requirements

    + +

    Sample Code

    +
    +
    #include <boost/preprocessor/punctuation/remove_parens.hpp>

    #define DATA data
    #define DATAP ( data ) more_data

    BOOST_PP_REMOVE_PARENS(DATA) // expands to 'data' +BOOST_PP_REMOVE_PARENS(DATAP) // expands to 'data more_data'
    +
    +
    +
    © Copyright Edward Diener 2014
    +
    +

    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)

    +
    + +