forked from boostorg/preprocessor
Added OPT macro to determine whether C++20's __VA_OPT__ is supported or not. Updated the undocumented variadic IS_EMPTY to use the functionality of __VA_OPT__ if it exists to provide perfect functionality for testing for emptiness.
This commit is contained in:
@ -16,6 +16,20 @@
|
|||||||
#
|
#
|
||||||
# if BOOST_PP_VARIADICS
|
# if BOOST_PP_VARIADICS
|
||||||
#
|
#
|
||||||
|
# include <boost/preprocessor/variadic/opt.hpp>
|
||||||
|
#
|
||||||
|
# if BOOST_PP_VARIADIC_OPT()
|
||||||
|
#
|
||||||
|
#define BOOST_PP_IS_EMPTY_FUNCTION2(...) \
|
||||||
|
__VA_OPT__(0,) 1 \
|
||||||
|
/**/
|
||||||
|
#define BOOST_PP_IS_EMPTY_FUNCTION(...) \
|
||||||
|
BOOST_PP_IS_EMPTY_FUNCTION2(__VA_ARGS__) \
|
||||||
|
/**/
|
||||||
|
#define BOOST_PP_IS_EMPTY(...) \
|
||||||
|
BOOST_PP_VARIADIC_OPT_ELEM0(BOOST_PP_IS_EMPTY_FUNCTION(__VA_ARGS__),) \
|
||||||
|
/**/
|
||||||
|
# else
|
||||||
# include <boost/preprocessor/punctuation/is_begin_parens.hpp>
|
# include <boost/preprocessor/punctuation/is_begin_parens.hpp>
|
||||||
# include <boost/preprocessor/facilities/detail/is_empty.hpp>
|
# include <boost/preprocessor/facilities/detail/is_empty.hpp>
|
||||||
#
|
#
|
||||||
@ -53,5 +67,6 @@
|
|||||||
/**/
|
/**/
|
||||||
#define BOOST_PP_IS_EMPTY_ZERO(...) 0
|
#define BOOST_PP_IS_EMPTY_ZERO(...) 0
|
||||||
# endif /* BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 */
|
# endif /* BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 */
|
||||||
|
# endif /* BOOST_PP_VARIADIC_OPT() */
|
||||||
# endif /* BOOST_PP_VARIADICS */
|
# endif /* BOOST_PP_VARIADICS */
|
||||||
# endif /* BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP */
|
# endif /* BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP */
|
||||||
|
30
include/boost/preprocessor/variadic/detail/opt.hpp
Normal file
30
include/boost/preprocessor/variadic/detail/opt.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# /* **************************************************************************
|
||||||
|
# * *
|
||||||
|
# * (C) Copyright Edward Diener 2019. *
|
||||||
|
# * 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_OPT_HPP
|
||||||
|
# define BOOST_PREPROCESSOR_VARIADIC_DETAIL_OPT_HPP
|
||||||
|
#
|
||||||
|
# include <boost/preprocessor/config/config.hpp>
|
||||||
|
#
|
||||||
|
# if BOOST_PP_VARIADICS && defined(__cplusplus) && __cplusplus > 201703L
|
||||||
|
#
|
||||||
|
# define BOOST_PP_VARIADIC_OPT_FUNCTION(...) \
|
||||||
|
__VA_OPT__(0,) 0, 0, 1 \
|
||||||
|
/**/
|
||||||
|
#
|
||||||
|
# define BOOST_PP_VARIADIC_OPT_ELEM0(e0, ...) BOOST_PP_VARIADIC_OPT_ELEM_0(e0,__VA_ARGS__)
|
||||||
|
# define BOOST_PP_VARIADIC_OPT_ELEM2(e0, ...) BOOST_PP_VARIADIC_OPT_ELEM_2(e0,__VA_ARGS__)
|
||||||
|
# define BOOST_PP_VARIADIC_OPT_ELEM_0(e0, ...) e0
|
||||||
|
# define BOOST_PP_VARIADIC_OPT_ELEM_2(e0, e1, e2, ...) e2
|
||||||
|
#
|
||||||
|
# endif
|
||||||
|
#
|
||||||
|
# endif
|
28
include/boost/preprocessor/variadic/opt.hpp
Normal file
28
include/boost/preprocessor/variadic/opt.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# /* **************************************************************************
|
||||||
|
# * *
|
||||||
|
# * (C) Copyright Edward Diener 2019. *
|
||||||
|
# * 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_OPT_HPP
|
||||||
|
# define BOOST_PREPROCESSOR_VARIADIC_OPT_HPP
|
||||||
|
#
|
||||||
|
# include <boost/preprocessor/config/config.hpp>
|
||||||
|
#
|
||||||
|
# /* BOOST_PP_VARIADIC_OPT */
|
||||||
|
#
|
||||||
|
# if BOOST_PP_VARIADICS && defined(__cplusplus) && __cplusplus > 201703L
|
||||||
|
# include <boost/preprocessor/variadic/detail/opt.hpp>
|
||||||
|
# define BOOST_PP_VARIADIC_OPT() \
|
||||||
|
BOOST_PP_VARIADIC_OPT_ELEM2(BOOST_PP_VARIADIC_OPT_FUNCTION(),) \
|
||||||
|
/**/
|
||||||
|
# else
|
||||||
|
# define BOOST_PP_VARIADIC_OPT() 0
|
||||||
|
# endif
|
||||||
|
#
|
||||||
|
# endif
|
@ -9,10 +9,7 @@
|
|||||||
#
|
#
|
||||||
# /* See http://www.boost.org for most recent version. */
|
# /* See http://www.boost.org for most recent version. */
|
||||||
#
|
#
|
||||||
# include <boost/preprocessor/cat.hpp>
|
# include <libs/preprocessor/test/test_macro.h>
|
||||||
#
|
|
||||||
# define BEGIN typedef int BOOST_PP_CAT(test_, __LINE__)[((
|
|
||||||
# define END )==1) ? 1 : -1];
|
|
||||||
|
|
||||||
#if defined(__clang__) && defined(__CUDACC__) && defined(__CUDA__)
|
#if defined(__clang__) && defined(__CUDACC__) && defined(__CUDA__)
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
|
#include <boost/preprocessor/variadic/opt.hpp>
|
||||||
|
|
||||||
static unsigned int indent = 4;
|
static unsigned int indent = 4;
|
||||||
static unsigned int width = 40;
|
static unsigned int width = 40;
|
||||||
@ -93,6 +94,8 @@ void print_macros()
|
|||||||
PRINT_MACRO(BOOST_PP_CONFIG_FLAGS());
|
PRINT_MACRO(BOOST_PP_CONFIG_FLAGS());
|
||||||
PRINT_MACRO(BOOST_PP_VARIADICS);
|
PRINT_MACRO(BOOST_PP_VARIADICS);
|
||||||
PRINT_MACRO(BOOST_PP_VARIADICS_MSVC);
|
PRINT_MACRO(BOOST_PP_VARIADICS_MSVC);
|
||||||
|
PRINT_MACRO(BOOST_PP_VARIADICS_MSVC);
|
||||||
|
PRINT_MACRO(BOOST_PP_VARIADIC_OPT());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -38,7 +38,20 @@
|
|||||||
|
|
||||||
#if BOOST_PP_VARIADICS
|
#if BOOST_PP_VARIADICS
|
||||||
|
|
||||||
#if BOOST_PP_VARIADICS_MSVC /* Testing the VC++ variadic version */
|
# include <boost/preprocessor/variadic/opt.hpp>
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus > 201703L && BOOST_PP_VARIADIC_OPT()
|
||||||
|
|
||||||
|
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_GEN9) == 0 END
|
||||||
|
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
|
||||||
|
|
||||||
|
#elif BOOST_PP_VARIADICS_MSVC /* Testing the VC++ variadic version */
|
||||||
|
|
||||||
/* INCORRECT */
|
/* INCORRECT */
|
||||||
|
|
||||||
|
@ -15,9 +15,19 @@
|
|||||||
#if BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && !BOOST_PP_VARIADICS_MSVC
|
#if BOOST_PP_VARIADICS && (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) && !BOOST_PP_VARIADICS_MSVC
|
||||||
|
|
||||||
#define FUNC_GEN8(x,y) (1,2,3)
|
#define FUNC_GEN8(x,y) (1,2,3)
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus > 201703L
|
||||||
|
|
||||||
|
# include <boost/preprocessor/variadic/opt.hpp>
|
||||||
|
|
||||||
|
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == BOOST_PP_VARIADIC_OPT() END
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
|
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
BEGIN 1 == 0 END
|
BEGIN 1 == 0 END
|
||||||
|
@ -16,8 +16,18 @@
|
|||||||
|
|
||||||
#define FUNC_GEN9(x,y,z) anything
|
#define FUNC_GEN9(x,y,z) anything
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus > 201703L
|
||||||
|
|
||||||
|
# include <boost/preprocessor/variadic/opt.hpp>
|
||||||
|
|
||||||
|
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == BOOST_PP_VARIADIC_OPT() END
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
|
BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
BEGIN 1 == 0 END
|
BEGIN 1 == 0 END
|
||||||
|
21
test/test.h
21
test/test.h
@ -14,24 +14,7 @@
|
|||||||
# ifndef BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_H
|
# ifndef BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_H
|
||||||
# define BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_H
|
# define BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_H
|
||||||
#
|
#
|
||||||
# include <boost/preprocessor/cat.hpp>
|
# include <libs/preprocessor/test/test_macro.h>
|
||||||
|
# include <libs/preprocessor/test/test_main.h>
|
||||||
#
|
#
|
||||||
# define BEGIN typedef int BOOST_PP_CAT(test_, __LINE__)[((
|
|
||||||
# define END )==1) ? 1 : -1];
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
#include <cstdio>
|
|
||||||
#if !defined(_STLP_MSVC) || _STLP_MSVC >= 1300
|
|
||||||
namespace std { }
|
|
||||||
using namespace std;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
printf("pass " __TIME__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
22
test/test_macro.h
Normal file
22
test/test_macro.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# /* Copyright (C) 2001
|
||||||
|
# * Housemarque Oy
|
||||||
|
# * http://www.housemarque.com
|
||||||
|
# *
|
||||||
|
# * 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 Paul Mensonides (2002) */
|
||||||
|
#
|
||||||
|
# /* See http://www.boost.org for most recent version. */
|
||||||
|
#
|
||||||
|
# ifndef BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_MACRO_H
|
||||||
|
# define BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_MACRO_H
|
||||||
|
#
|
||||||
|
# include <boost/preprocessor/cat.hpp>
|
||||||
|
#
|
||||||
|
# define BEGIN typedef int BOOST_PP_CAT(test_, __LINE__)[((
|
||||||
|
# define END )==1) ? 1 : -1];
|
||||||
|
#
|
||||||
|
# endif
|
32
test/test_main.h
Normal file
32
test/test_main.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# /* Copyright (C) 2001
|
||||||
|
# * Housemarque Oy
|
||||||
|
# * http://www.housemarque.com
|
||||||
|
# *
|
||||||
|
# * 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 Paul Mensonides (2002) */
|
||||||
|
#
|
||||||
|
# /* See http://www.boost.org for most recent version. */
|
||||||
|
#
|
||||||
|
# ifndef BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_MAIN_H
|
||||||
|
# define BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_MAIN_H
|
||||||
|
#
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#include <cstdio>
|
||||||
|
#if !defined(_STLP_MSVC) || _STLP_MSVC >= 1300
|
||||||
|
namespace std { }
|
||||||
|
using namespace std;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
printf("pass " __TIME__);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif
|
Reference in New Issue
Block a user