The BOOST_PP_CHECK_EMPTY variadic macro checks to see if its variadic input is empty or not. It expands to 1 if its input is empty and expands to 0 if its input is not empty. The macro only exists when the compilation is at the C++20 level and the __VA_OPT__ construct is supported.

Usage

BOOST_PP_CHECK_EMPTY(...) (v)

Arguments

...
The variadic data to be checked for emptiness.

Remarks

When the macro invocation BOOST_PP_VARIADIC_HAS_OPT() expands to 1, then this macro exists and can be invoked, otherwise this macro does not exist and attempting to invoke it will lead to a preprocessor error that the macro can not be found. Because of this condition the header file for including this macro includes the header file for the BOOST_PP_VARIADIC_HAS_OPT macro.
It is possible to pass data to this macro which expands to nothing, in which case this macro will expand to 1 just as if nothing has been passed.

See Also

Requirements

Header:  <boost/preprocessor/facilities/check_empty.hpp>

Sample Code

#include <boost/preprocessor/facilities/check_empty.hpp>

# if BOOST_PP_VARIADIC_HAS_OPT()

#define DATA
#define OBJECT OBJECT2
#define OBJECT2
#define FUNC(x) FUNC2(x)
#define FUNC2(x)
#define FUNC_GEN(x,y) (1,2,3)

BOOST_PP_CHECK_EMPTY(DATA)     // expands to 1
BOOST_PP_CHECK_EMPTY(OBJECT)   // expands to 1
BOOST_PP_CHECK_EMPTY(FUNC(1))  // expands to 1
BOOST_PP_CHECK_EMPTY(FUNC)     // expands to 0
BOOST_PP_CHECK_EMPTY(FUNC_GEN) // expands to 0

#endif

Copyright Edward Diener 2019

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)