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:
Edward Diener
2019-09-25 06:29:04 -04:00
parent c436de6142
commit e476f10f52
11 changed files with 167 additions and 24 deletions

View File

@ -16,6 +16,20 @@
#
# 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/facilities/detail/is_empty.hpp>
#
@ -53,5 +67,6 @@
/**/
#define BOOST_PP_IS_EMPTY_ZERO(...) 0
# endif /* BOOST_PP_VARIADICS_MSVC && _MSC_VER <= 1400 */
# endif /* BOOST_PP_VARIADIC_OPT() */
# endif /* BOOST_PP_VARIADICS */
# endif /* BOOST_PREPROCESSOR_FACILITIES_IS_EMPTY_VARIADIC_HPP */

View 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

View 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