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