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. |
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 | returns = Normally the macro returns nothing. |
45 | |
46 | If the sequence is an identifier, nothing is |
47 | output. If optional ids are specified, for the |
48 | sequence to be an identifier it must be an |
49 | identifier that matches one of the optional |
50 | ids. |
51 | |
52 | For VC++, because there is no sure way of forcing |
53 | a compiler error from within a macro without producing |
54 | output, if the sequence is not an identifier the |
55 | macro forces a compiler error by outputting invalid C++. |
56 | |
57 | For all other compilers a compiler error is forced |
58 | without producing output if the sequence is not an |
59 | identifier. |
60 | |
61 | Identifiers are registered in VMD with: |
62 | |
63 | #define BOOST_VMD_REG_XXX (XXX) where XXX is a v-identifier. |
64 | |
65 | The identifier must be registered to be found. |
66 | |
67 | Identifiers are pre-detected in VMD with: |
68 | |
69 | #define BOOST_VMD_DETECT_XXX_XXX where XXX is an identifier. |
70 | |
71 | If you specify optional ids and have not specified the detection |
72 | of an optional id, that id will never match an identifier. |
73 | |
74 | */ |
75 | |
76 | /** \def BOOST_VMD_ASSERT_IS_IDENTIFIER_D(d,...) |
77 | |
78 | \brief Asserts that the sequence is an identifier. Re-entrant version. |
79 | |
80 | The macro checks that the sequence is an identifier. |
81 | If it is not an identifier, it forces a compiler error. |
82 | |
83 | The macro normally checks for an identifier only in |
84 | debug mode. However an end-user can force the macro |
85 | to check or not check by defining the macro |
86 | BOOST_VMD_ASSERT_DATA to 1 or 0 respectively. |
87 | |
88 | d = The next available BOOST_PP_WHILE iteration. |
89 | ... = variadic parameters |
90 | |
91 | The variadic parameters are: |
92 | |
93 | sequence = A sequence to test as an identifier. |
94 | ids (optional) = The data may take one of two forms: |
95 | it is either one or more single identifiers |
96 | or a single Boost PP tuple of identifiers. |
97 | |
98 | returns = Normally the macro returns nothing. |
99 | |
100 | If the sequence is an identifier, nothing is |
101 | output. If optional ids are specified, for the |
102 | sequence to be an identifier it must be an |
103 | identifier that matches one of the optional |
104 | ids. |
105 | |
106 | For VC++, because there is no sure way of forcing |
107 | a compiler error from within a macro without producing |
108 | output, if the sequence is not an identifier the |
109 | macro forces a compiler error by outputting invalid C++. |
110 | |
111 | For all other compilers a compiler error is forced |
112 | without producing output if the sequence is not an |
113 | identifier. |
114 | |
115 | Identifiers are registered in VMD with: |
116 | |
117 | #define BOOST_VMD_REG_XXX (XXX) where XXX is a v-identifier. |
118 | |
119 | The identifier must be registered to be found. |
120 | |
121 | Identifiers are pre-detected in VMD with: |
122 | |
123 | #define BOOST_VMD_DETECT_XXX_XXX where XXX is an identifier. |
124 | |
125 | If you specify optional ids and have not specified the detection |
126 | of an optional id, that id will never match an identifier. |
127 | |
128 | */ |
129 | |
130 | #if !BOOST_VMD_ASSERT_DATA |
131 | |
132 | #define BOOST_VMD_ASSERT_IS_IDENTIFIER(...) |
133 | #define BOOST_VMD_ASSERT_IS_IDENTIFIER_D(d,...) |
134 | |
135 | #else |
136 | |
137 | #include <boost/vmd/assert.hpp> |
138 | #include <boost/vmd/is_identifier.hpp> |
139 | |
140 | #define BOOST_VMD_ASSERT_IS_IDENTIFIER(...) \ |
141 | BOOST_VMD_ASSERT \ |
142 | ( \ |
143 | BOOST_VMD_IS_IDENTIFIER(__VA_ARGS__), \ |
144 | BOOST_VMD_IDENTIFIER_ASSERT_ERROR \ |
145 | ) \ |
146 | /**/ |
147 | |
148 | #define BOOST_VMD_ASSERT_IS_IDENTIFIER_D(d,...) \ |
149 | BOOST_VMD_ASSERT \ |
150 | ( \ |
151 | BOOST_VMD_IS_IDENTIFIER_D(d,__VA_ARGS__), \ |
152 | BOOST_VMD_IDENTIFIER_ASSERT_ERROR \ |
153 | ) \ |
154 | /**/ |
155 | |
156 | #endif // !BOOST_VMD_ASSERT_DATA |
157 | #endif /* BOOST_PP_VARIADICS */ |
158 | #endif /* BOOST_VMD_ASSERT_IS_IDENTIFIER_HPP */ |
159 | |