1 2 // (C) Copyright Edward Diener 2011-2015 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_ASSERT_IS_IDENTIFIER_HPP) 8 #define BOOST_VMD_ASSERT_IS_IDENTIFIER_HPP 9 10 #include <boost/vmd/detail/setup.hpp> 11 12 #if BOOST_PP_VARIADICS 13 14 /* 15 16 The succeeding comments in this file are in doxygen format. 17 18 */ 19 20 /** \file 21 */ 22 23 /** \def BOOST_VMD_ASSERT_IS_IDENTIFIER(...) 24 25 \brief Asserts that the sequence is an identifier. 26 27 The macro checks that the sequence is an identifier. 28 If it is not an identifier, it forces a compiler error. 29 30 The macro normally checks for an identifier only in 31 debug mode. However an end-user can force the macro 32 to check or not check by defining the macro 33 BOOST_VMD_ASSERT_DATA to 1 or 0 respectively. 34 35 ... = variadic parameters 36 37 The variadic parameters are: 38 39 sequence = A sequence to test as an identifier. <br/> 40 ids (optional) = The data may take one of two forms: 41 it is either one or more single identifiers 42 or a single Boost PP tuple of identifiers. 43 44 @code 45 46 returns = Normally the macro returns nothing. 47 48 If the sequence is an identifier, nothing is 49 output. If optional ids are specified, for the 50 sequence to be an identifier it must be an 51 identifier that matches one of the optional 52 ids. 53 54 For VC++, because there is no sure way of forcing 55 a compiler error from within a macro without producing 56 output, if the sequence is not an identifier the 57 macro forces a compiler error by outputting invalid C++. 58 59 For all other compilers a compiler error is forced 60 without producing output if the sequence is not an 61 identifier. 62 63 @endcode 64 65 Identifiers are registered in VMD with: 66 67 @code 68 69 #define BOOST_VMD_REG_XXX (XXX) where XXX is a v-identifier. 70 71 @endcode 72 73 The identifier must be registered to be found. 74 75 Identifiers are pre-detected in VMD with: 76 77 @code 78 79 #define BOOST_VMD_DETECT_XXX_XXX where XXX is an identifier. 80 81 @endcode 82 83 If you specify optional ids and have not specified the detection 84 of an optional id, that id will never match an identifier. 85 86 */ 87 88 /** \def BOOST_VMD_ASSERT_IS_IDENTIFIER_D(d,...) 89 90 \brief Asserts that the sequence is an identifier. Re-entrant version. 91 92 The macro checks that the sequence is an identifier. 93 If it is not an identifier, it forces a compiler error. 94 95 The macro normally checks for an identifier only in 96 debug mode. However an end-user can force the macro 97 to check or not check by defining the macro 98 BOOST_VMD_ASSERT_DATA to 1 or 0 respectively. 99 100 d = The next available BOOST_PP_WHILE iteration. <br/> 101 ... = variadic parameters 102 103 The variadic parameters are: 104 105 sequence = A sequence to test as an identifier. <br/> 106 ids (optional) = The data may take one of two forms: 107 it is either one or more single identifiers 108 or a single Boost PP tuple of identifiers. 109 110 @code 111 112 returns = Normally the macro returns nothing. 113 114 If the sequence is an identifier, nothing is 115 output. If optional ids are specified, for the 116 sequence to be an identifier it must be an 117 identifier that matches one of the optional 118 ids. 119 120 For VC++, because there is no sure way of forcing 121 a compiler error from within a macro without producing 122 output, if the sequence is not an identifier the 123 macro forces a compiler error by outputting invalid C++. 124 125 For all other compilers a compiler error is forced 126 without producing output if the sequence is not an 127 identifier. 128 129 @endcode 130 131 Identifiers are registered in VMD with: 132 133 @code 134 135 #define BOOST_VMD_REG_XXX (XXX) where XXX is a v-identifier. 136 137 @endcode 138 139 The identifier must be registered to be found. 140 141 Identifiers are pre-detected in VMD with: 142 143 @code 144 145 #define BOOST_VMD_DETECT_XXX_XXX where XXX is an identifier. 146 147 @endcode 148 149 If you specify optional ids and have not specified the detection 150 of an optional id, that id will never match an identifier. 151 152 */ 153 154 #if !BOOST_VMD_ASSERT_DATA 155 156 #define BOOST_VMD_ASSERT_IS_IDENTIFIER(...) 157 #define BOOST_VMD_ASSERT_IS_IDENTIFIER_D(d,...) 158 159 #else 160 161 #include <boost/vmd/assert.hpp> 162 #include <boost/vmd/is_identifier.hpp> 163 164 #define BOOST_VMD_ASSERT_IS_IDENTIFIER(...) \ 165 BOOST_VMD_ASSERT \ 166 ( \ 167 BOOST_VMD_IS_IDENTIFIER(__VA_ARGS__), \ 168 BOOST_VMD_IDENTIFIER_ASSERT_ERROR \ 169 ) \ 170 /**/ 171 172 #define BOOST_VMD_ASSERT_IS_IDENTIFIER_D(d,...) \ 173 BOOST_VMD_ASSERT \ 174 ( \ 175 BOOST_VMD_IS_IDENTIFIER_D(d,__VA_ARGS__), \ 176 BOOST_VMD_IDENTIFIER_ASSERT_ERROR \ 177 ) \ 178 /**/ 179 180 #endif // !BOOST_VMD_ASSERT_DATA 181 #endif /* BOOST_PP_VARIADICS */ 182 #endif /* BOOST_VMD_ASSERT_IS_IDENTIFIER_HPP */ 183