Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / vmd / is_empty.hpp
1
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).
6
7 #if !defined(BOOST_VMD_IS_EMPTY_HPP)
8 #define BOOST_VMD_IS_EMPTY_HPP
9
10 #include <boost/vmd/detail/setup.hpp>
11
12 #if BOOST_PP_VARIADICS
13
14 #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
15 #include <boost/vmd/detail/is_empty.hpp>
16
17 /*
18
19   The succeeding comments in this file are in doxygen format.
20
21 */
22
23 /** \file
24 */
25
26 /** \def BOOST_VMD_IS_EMPTY(...)
27
28     \brief Tests whether its input is empty or not.
29
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.
32     
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.
35     
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.
40     
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.
44     
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.
53     
54     ... = variadic input, for VC++8 this must be a single parameter
55
56     returns = 1 if the input is empty, 0 if it is not
57     
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.
62     
63 */
64
65 #if BOOST_VMD_MSVC_V8
66
67 #define BOOST_VMD_IS_EMPTY(sequence) \
68     BOOST_VMD_DETAIL_IS_EMPTY_IIF \
69       ( \
70       BOOST_PP_IS_BEGIN_PARENS \
71         ( \
72         sequence \
73         ) \
74       ) \
75       ( \
76       BOOST_VMD_DETAIL_IS_EMPTY_GEN_ZERO, \
77       BOOST_VMD_DETAIL_IS_EMPTY_PROCESS \
78       ) \
79     (sequence) \
80 /**/
81
82 #else
83
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 \
89       ( \
90       BOOST_PP_VARIADIC_HAS_OPT() \
91       ) \
92       ( \
93       BOOST_PP_IS_EMPTY_OPT, \
94       BOOST_VMD_IS_EMPTY_NO_OPT \
95       ) \
96     (__VA_ARGS__) \
97 /**/
98 # else
99 #define BOOST_VMD_IS_EMPTY(...) \
100     BOOST_VMD_IS_EMPTY_NO_OPT(__VA_ARGS__) \
101 /**/
102 # endif
103 #define BOOST_VMD_IS_EMPTY_NO_OPT(...) \
104     BOOST_VMD_DETAIL_IS_EMPTY_IIF \
105       ( \
106       BOOST_PP_IS_BEGIN_PARENS \
107         ( \
108         __VA_ARGS__ \
109         ) \
110       ) \
111       ( \
112       BOOST_VMD_DETAIL_IS_EMPTY_GEN_ZERO, \
113       BOOST_VMD_DETAIL_IS_EMPTY_PROCESS \
114       ) \
115     (__VA_ARGS__) \
116 /**/
117 #endif /* BOOST_VMD_MSVC_V8 */
118 #endif /* BOOST_PP_VARIADICS */
119 #endif /* BOOST_VMD_IS_EMPTY_HPP */