Addition of is_empty tests and changes to rem processing as a workaround to VC++ problem.

This commit is contained in:
Edward Diener
2014-04-30 16:06:49 -04:00
parent 2c7cf9410a
commit 4ed6f6e07a
24 changed files with 476 additions and 66 deletions

View File

@ -23,9 +23,7 @@
# #
# /* BOOST_PP_ARRAY_DETAIL_GET_DATA */ # /* 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_SINGLE(size, data) BOOST_PP_TUPLE_REM_CAT(size) data
# 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_ANY(size, data) BOOST_PP_TUPLE_REM(size) data
# define BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO(size, data) \ # define BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO(size, data) \
BOOST_PP_IF \ BOOST_PP_IF \

View File

@ -22,10 +22,13 @@
# else # else
# #
# include <boost/preprocessor/config/config.hpp> # include <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/cat.hpp> # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() && ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC()
# include <boost/preprocessor/tuple/elem.hpp> # include <boost/preprocessor/tuple/elem.hpp>
# include <boost/preprocessor/facilities/empty.hpp> # include <boost/preprocessor/facilities/empty.hpp>
# else
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/detail/split.hpp> # include <boost/preprocessor/detail/split.hpp>
# endif
# #
# /* BOOST_PP_IS_EMPTY */ # /* BOOST_PP_IS_EMPTY */
# #

View File

@ -16,6 +16,9 @@
# include <boost/preprocessor/config/config.hpp> # include <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/tuple/eat.hpp> # include <boost/preprocessor/tuple/eat.hpp>
# include <boost/preprocessor/tuple/rem.hpp> # include <boost/preprocessor/tuple/rem.hpp>
# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC
# include <boost/preprocessor/variadic/detail/is_single_return.hpp>
# endif
# #
# /* BOOST_PP_SEQ_BINARY_TRANSFORM */ # /* 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) # define BOOST_PP_SEQ_BINARY_TRANSFORM(seq) BOOST_PP_CAT(BOOST_PP_SEQ_BINARY_TRANSFORM_A seq, 0)
# endif # endif
# if BOOST_PP_VARIADICS # if BOOST_PP_VARIADICS
# define BOOST_PP_SEQ_BINARY_TRANSFORM_A(...) (BOOST_PP_REM, __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_B # if BOOST_PP_VARIADICS_MSVC
# define BOOST_PP_SEQ_BINARY_TRANSFORM_B(...) (BOOST_PP_REM, __VA_ARGS__)() BOOST_PP_SEQ_BINARY_TRANSFORM_A # 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 # 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_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 # define BOOST_PP_SEQ_BINARY_TRANSFORM_B(e) (BOOST_PP_REM, e)() BOOST_PP_SEQ_BINARY_TRANSFORM_A

View File

@ -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 <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/control/iif.hpp>
# include <boost/preprocessor/facilities/is_1.hpp>
# include <boost/preprocessor/tuple/size.hpp>
#
# /* 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 */

View File

@ -22,9 +22,7 @@
# include <boost/preprocessor/variadic/elem.hpp> # include <boost/preprocessor/variadic/elem.hpp>
# #
# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC # if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC
# include <boost/preprocessor/comparison/equal.hpp> # include <boost/preprocessor/tuple/detail/is_single_return.hpp>
# include <boost/preprocessor/control/iif.hpp>
# include <boost/preprocessor/tuple/size.hpp>
# endif # endif
# #
# if BOOST_PP_VARIADICS # 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_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args)
# define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(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 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) \ # define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) \
BOOST_PP_IIF \ BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_TUPLE_IS_SINGLE_RETURN(BOOST_PP_REM_CAT,BOOST_PP_REM,tuple) tuple) \
( \
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 # else
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__) # define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__)

View File

@ -16,10 +16,17 @@
# include <boost/preprocessor/cat.hpp> # include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/config/config.hpp> # include <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/facilities/overload.hpp> # include <boost/preprocessor/facilities/overload.hpp>
# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC
# include <boost/preprocessor/tuple/detail/is_single_return.hpp>
# endif
# #
# /* BOOST_PP_REM */ # /* BOOST_PP_REM */
# #
# if BOOST_PP_VARIADICS # 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__ # define BOOST_PP_REM(...) __VA_ARGS__
# else # else
# define BOOST_PP_REM(x) x # define BOOST_PP_REM(x) x
@ -31,6 +38,10 @@
VC++8.0 cannot handle the variadic version of BOOST_PP_TUPLE_REM(size) 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
# endif
# define BOOST_PP_TUPLE_REM(size) BOOST_PP_REM # define BOOST_PP_TUPLE_REM(size) BOOST_PP_REM
# else # else
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() # 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(...) 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_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_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 # 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(...) 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 # 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) # define BOOST_PP_TUPLE_REM_CTOR_O_2(size, tuple) BOOST_PP_TUPLE_REM_CTOR_O_1(tuple)
# else # else
# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()

View File

@ -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 <boost/preprocessor/config/config.hpp>
# include <boost/preprocessor/control/iif.hpp>
# include <boost/preprocessor/facilities/is_1.hpp>
# include <boost/preprocessor/variadic/size.hpp>
#
# /* 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 */

View File

@ -19,23 +19,22 @@ project preprocessor_tests : requirements <warnings>on
test-suite preprocessor test-suite preprocessor
: :
[ compile arithmetic.cpp ] [ compile arithmetic.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile array.cpp ] [ compile array.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile comparison.cpp ] [ compile comparison.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile control.cpp ] [ compile control.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile debug.cpp ] [ compile debug.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile facilities.cpp ] [ compile facilities.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile isempty.cpp ] [ compile iteration.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile iteration.cpp ] [ compile list.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile list.cpp ] [ compile logical.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile logical.cpp ] [ compile punctuation.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile punctuation.cpp ] [ compile repetition.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile repetition.cpp ] [ compile selection.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile selection.cpp ] [ compile seq.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile seq.cpp ] [ compile slot.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile slot.cpp ] [ compile tuple.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile tuple.cpp ] [ compile variadic.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
[ compile variadic.cpp ]
; ;
test-suite preprocessor_nvm test-suite preprocessor_nvm
@ -46,7 +45,6 @@ test-suite preprocessor_nvm
[ compile control.cpp : <define>BOOST_PP_VARIADICS=0 : control_nvm ] [ compile control.cpp : <define>BOOST_PP_VARIADICS=0 : control_nvm ]
[ compile debug.cpp : <define>BOOST_PP_VARIADICS=0 : debug_nvm ] [ compile debug.cpp : <define>BOOST_PP_VARIADICS=0 : debug_nvm ]
[ compile facilities.cpp : <define>BOOST_PP_VARIADICS=0 : facilities_nvm ] [ compile facilities.cpp : <define>BOOST_PP_VARIADICS=0 : facilities_nvm ]
[ compile isempty.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_nvm ]
[ compile iteration.cpp : <define>BOOST_PP_VARIADICS=0 : iteration_nvm ] [ compile iteration.cpp : <define>BOOST_PP_VARIADICS=0 : iteration_nvm ]
[ compile list.cpp : <define>BOOST_PP_VARIADICS=0 : list_nvm ] [ compile list.cpp : <define>BOOST_PP_VARIADICS=0 : list_nvm ]
[ compile logical.cpp : <define>BOOST_PP_VARIADICS=0 : logical_nvm ] [ compile logical.cpp : <define>BOOST_PP_VARIADICS=0 : logical_nvm ]
@ -83,10 +81,6 @@ test-suite preprocessor_c
: <toolset>gcc:<cflags>-std=c99 : <toolset>gcc:<cflags>-std=c99
: facilities_c : facilities_c
] ]
[ compile isempty.c
: <toolset>gcc:<cflags>-std=c99
: isempty_c
]
[ compile list.c [ compile list.c
: <toolset>gcc:<cflags>-std=c99 : <toolset>gcc:<cflags>-std=c99
: list_c : list_c
@ -153,11 +147,6 @@ test-suite preprocessor_c_nvm
<toolset>gcc:<cflags>-std=c99 <toolset>gcc:<cflags>-std=c99
: facilities_c_nvm : facilities_c_nvm
] ]
[ compile isempty.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_c_nvm
]
[ compile list.c [ compile list.c
: <define>BOOST_PP_VARIADICS=0 : <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99 <toolset>gcc:<cflags>-std=c99
@ -189,3 +178,52 @@ test-suite preprocessor_c_nvm
: tuple_c_nvm : tuple_c_nvm
] ]
; ;
# test-suite preprocessor_isempty
# :
# [ compile isempty.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
# [ compile-fail isempty_variadic_standard_failure.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
# [ compile-fail isempty_variadic_standard_failure2.cpp : <toolset>gcc:<cxxflags>-std=c++0x ]
# ;
test-suite preprocessor_isempty_nvm
:
[ compile isempty.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_nvm ]
[ compile-fail isempty_failure.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_failure_nvm ]
[ compile-fail isempty_failure2.cpp : <define>BOOST_PP_VARIADICS=0 : isempty_failure2_nvm ]
;
# test-suite preprocessor_isempty_c
# :
# [ compile isempty.c
# : <toolset>gcc:<cflags>-std=c99
# : isempty_c
# ]
# [ compile-fail isempty_variadic_standard_failure.c
# : <toolset>gcc:<cflags>-std=c99
# : isempty_variadic_standard_failure_c
# ]
# [ compile-fail isempty_variadic_standard_failure2.c
# : <toolset>gcc:<cflags>-std=c99
# : isempty_variadic_standard_failure2_c
# ]
# ;
test-suite preprocessor_isempty_c_nvm
:
[ compile isempty.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_c_nvm
]
[ compile-fail isempty_failure.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_failure_c_nvm
]
[ compile-fail isempty_failure2.c
: <define>BOOST_PP_VARIADICS=0
<toolset>gcc:<cflags>-std=c99
: isempty_failure2_c_nvm
]
;

View File

@ -1,6 +1,6 @@
# /* ************************************************************************** # /* **************************************************************************
# * * # * *
# * (C) Copyright Paul Mensonides 2002. # * (C) Copyright Edward Diener 2014.
# * Distributed under the Boost Software License, Version 1.0. (See # * Distributed under the Boost Software License, Version 1.0. (See
# * accompanying file LICENSE_1_0.txt or copy at # * accompanying file LICENSE_1_0.txt or copy at
# * http://www.boost.org/LICENSE_1_0.txt) # * http://www.boost.org/LICENSE_1_0.txt)

View File

@ -11,12 +11,8 @@
# #
# include <boost/preprocessor/facilities/empty.hpp> # include <boost/preprocessor/facilities/empty.hpp>
# include <boost/preprocessor/facilities/is_empty.hpp> # include <boost/preprocessor/facilities/is_empty.hpp>
# include <boost/preprocessor/facilities/is_empty_or_1.hpp>
# include <boost/preprocessor/facilities/is_1.hpp>
# include <libs/preprocessor/test/test.h> # include <libs/preprocessor/test/test.h>
#if BOOST_PP_VARIADICS
#define DATA #define DATA
#define OBJECT OBJECT2 #define OBJECT OBJECT2
#define OBJECT2 #define OBJECT2
@ -29,38 +25,53 @@
#define FUNC_GEN5() (y,z) #define FUNC_GEN5() (y,z)
#define FUNC_GEN6() anything #define FUNC_GEN6() anything
#define FUNC_GEN7(x) anything #define FUNC_GEN7(x) anything
#if defined(BOOST_PP_VARIADICS_MSVC)
#define FUNC_GEN8(x,y) (1,2,3) #define FUNC_GEN8(x,y) (1,2,3)
#define FUNC_GEN9(x,y,z) anything #define FUNC_GEN9(x,y,z) anything
#define FUNC_GEN10(x) (y) data
/* These next five produce the wrong result in VC++ */ #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_GEN) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 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_GEN3) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 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_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_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 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_GEN) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 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_GEN3) == 0 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 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_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 #endif
/* Testing the variadic version */
/* CORRECT */
BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END 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(DATA BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 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(z) BOOST_PP_EMPTY()) == 1 END
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 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_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 #endif

12
test/isempty_failure.c Normal file
View File

@ -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 <libs/preprocessor/test/isempty_failure.cxx>

12
test/isempty_failure.cpp Normal file
View File

@ -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 <libs/preprocessor/test/isempty_failure.cxx>

25
test/isempty_failure.cxx Normal file
View File

@ -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 <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#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

12
test/isempty_failure2.c Normal file
View File

@ -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 <libs/preprocessor/test/isempty_failure2.cxx>

12
test/isempty_failure2.cpp Normal file
View File

@ -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 <libs/preprocessor/test/isempty_failure2.cxx>

25
test/isempty_failure2.cxx Normal file
View File

@ -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 <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#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

View File

@ -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 <libs/preprocessor/test/isempty_variadic_standard_failure.cxx>

View File

@ -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 <libs/preprocessor/test/isempty_variadic_standard_failure.cxx>

View File

@ -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 <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#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

View File

@ -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 <libs/preprocessor/test/isempty_variadic_standard_failure2.cxx>

View File

@ -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 <libs/preprocessor/test/isempty_variadic_standard_failure2.cxx>

View File

@ -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 <boost/preprocessor/facilities/is_empty.hpp>
# include <libs/preprocessor/test/test.h>
#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

View File

@ -7,10 +7,12 @@
# * * # * *
# ************************************************************************** */ # ************************************************************************** */
# #
# /* Revised by Edward Diener (2011) */ # /* Revised by Edward Diener (2011,2014) */
# #
# /* See http://www.boost.org for most recent version. */ # /* See http://www.boost.org for most recent version. */
# #
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/control/if.hpp>
# include <boost/preprocessor/tuple.hpp> # include <boost/preprocessor/tuple.hpp>
# include <boost/preprocessor/array/elem.hpp> # include <boost/preprocessor/array/elem.hpp>
# include <boost/preprocessor/list/at.hpp> # include <boost/preprocessor/list/at.hpp>
@ -20,6 +22,7 @@
# include <boost/preprocessor/variadic/elem.hpp> # include <boost/preprocessor/variadic/elem.hpp>
# endif # endif
# include <libs/preprocessor/test/test.h> # include <libs/preprocessor/test/test.h>
# include <libs/preprocessor/test/tuple_elem_bug_test.cxx>
# define TUPLE (0, 1, 2, 3, 4, 5) # 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) # 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)

View File

@ -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 <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/control/if.hpp>
# include <boost/preprocessor/tuple.hpp>
# include <libs/preprocessor/test/test.h>
#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