2 // (C) Copyright Edward Diener 2011-2015,2019
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 #if !defined(BOOST_VMD_IS_EMPTY_HPP)
8 #define BOOST_VMD_IS_EMPTY_HPP
10 #include <boost/vmd/detail/setup.hpp>
12 #if BOOST_PP_VARIADICS
14 #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
15 #include <boost/vmd/detail/is_empty.hpp>
19 The succeeding comments in this file are in doxygen format.
26 /** \def BOOST_VMD_IS_EMPTY(...)
28 \brief Tests whether its input is empty or not.
30 The macro checks to see if the input is empty or not.
31 It returns 1 if the input is empty, else returns 0.
33 The macro is a variadic macro taking any input.
34 For the VC++8 compiler (VS2005) the macro takes a single parameter of input to check.
36 For all levels of C++ prior to C++20 the macro is not perfect,
37 and can not be so. The problem area is if the input to be
38 checked is a function-like macro name, in which case either
39 a compiler error can result or a false result can occur.
41 For C++20, with its support for the new __VA_OPT__ preprocessor
42 construct, the macro will always work correctly no matter what
43 the variadic input, and is therefore 100% reliable.
45 This macro is a replacement, using variadic macro support,
46 for the undocumented macro BOOST_PP_IS_EMPTY in the Boost
47 PP library. The code is taken from a posting by Paul Mensonides
48 of a variadic version for BOOST_PP_IS_EMPTY, and changed
49 in order to also support VC++. The code for the C++20
50 implementation of the macro, using the __VA_OPT__ preprocessor
51 construct, is the author's own and reuses code added to the
52 Boost preprocessor library by this author.
54 ... = variadic input, for VC++8 this must be a single parameter
56 returns = 1 if the input is empty, 0 if it is not
58 It is recommended to append BOOST_PP_EMPTY() to whatever input
59 is being tested in order to avoid possible warning messages
60 from some compilers about no parameters being passed to the macro
61 when the input is truly empty.
67 #define BOOST_VMD_IS_EMPTY(sequence) \
68 BOOST_VMD_DETAIL_IS_EMPTY_IIF \
70 BOOST_PP_IS_BEGIN_PARENS \
76 BOOST_VMD_DETAIL_IS_EMPTY_GEN_ZERO, \
77 BOOST_VMD_DETAIL_IS_EMPTY_PROCESS \
84 # if defined(__cplusplus) && __cplusplus > 201703L
85 #include <boost/preprocessor/variadic/has_opt.hpp>
86 #include <boost/preprocessor/facilities/is_empty.hpp>
87 #define BOOST_VMD_IS_EMPTY(...) \
88 BOOST_VMD_DETAIL_IS_EMPTY_IIF \
90 BOOST_PP_VARIADIC_HAS_OPT() \
93 BOOST_PP_IS_EMPTY_OPT, \
94 BOOST_VMD_IS_EMPTY_NO_OPT \
99 #define BOOST_VMD_IS_EMPTY(...) \
100 BOOST_VMD_IS_EMPTY_NO_OPT(__VA_ARGS__) \
103 #define BOOST_VMD_IS_EMPTY_NO_OPT(...) \
104 BOOST_VMD_DETAIL_IS_EMPTY_IIF \
106 BOOST_PP_IS_BEGIN_PARENS \
112 BOOST_VMD_DETAIL_IS_EMPTY_GEN_ZERO, \
113 BOOST_VMD_DETAIL_IS_EMPTY_PROCESS \
117 #endif /* BOOST_VMD_MSVC_V8 */
118 #endif /* BOOST_PP_VARIADICS */
119 #endif /* BOOST_VMD_IS_EMPTY_HPP */