113 {
114 public:
116 static constexpr Tag
Empty = 0;
117
118
119
121
123 contains_type<T, Types...>
::value>::type>
126 }
127
128 template <typename T, typename = typename fl::enable_if<
132 }
133
135 if (!other.empty()) {
136 copy_construct_from(other);
137 }
138 }
139
141 if (!other.empty()) {
142 move_construct_from(other);
143
145 }
146 }
147
149
151 if (this != &other) {
152 reset();
153 if (!other.empty()) {
154 copy_construct_from(other);
155 }
156 }
157 return *this;
158 }
159
161 if (this != &other) {
162 reset();
163 if (!other.empty()) {
164 move_construct_from(other);
165
167 }
168 }
169 return *this;
170 }
171
172 template <typename T, typename = typename fl::enable_if<
175
176
178 reset();
180 return *this;
181 }
182
183 template <typename T, typename = typename fl::enable_if<
186 reset();
188 return *this;
189 }
190
191
192
193 template <typename T, typename... Args>
196 reset();
198 return *ptr<T>();
199 }
200
202 if (!empty()) {
203 destroy_current();
205 }
206 }
207
210
212 return _tag == type_to_tag<T>();
213 }
214
216 if (!is<T>()) return nullptr;
217
218
220 }
221
222 template <
typename T>
const T *ptr() const
FL_NO_EXCEPT {
223 if (!is<T>()) return nullptr;
224
225
227 }
228
235
236
237 return *ptr<T>();
238 }
239
246
247
248 return *ptr<T>();
249 }
250
251 template <
typename T>
bool equals(
const T &other)
const FL_NO_EXCEPT {
252 if (auto p = ptr<T>()) {
253 return *p == other;
254 }
255 return false;
256 }
257
258
259 template <
typename Visitor>
void visit(Visitor &visitor)
FL_NO_EXCEPT {
261 return;
262
263
264 using Fn = void (*)(void *, Visitor &);
265
266
267
268
269 static constexpr Fn table[] = {
270 &variant::template visit_fn<Types, Visitor>...};
271
272
273
274 size_t index = _tag - 1;
275 if (index < sizeof...(Types)) {
276 table[index](&_storage, visitor);
277 }
278 }
279
280 template <
typename Visitor>
void visit(Visitor &visitor)
const FL_NO_EXCEPT {
282 return;
283
284
285 using Fn = void (*)(const void *, Visitor &);
286
287
288 static constexpr Fn table[] = {
289 &variant::template visit_fn_const<Types, Visitor>...};
290
291
292
293 size_t index = _tag - 1;
294 if (index < sizeof...(Types)) {
295 table[index](&_storage, visitor);
296 }
297 }
298
299 private:
300
301 template <typename T, typename Visitor>
302 static void visit_fn(
void *storage, Visitor &v)
FL_NO_EXCEPT {
303
304
306 v.accept(*typed_ptr);
307 }
308
309 template <typename T, typename Visitor>
310 static void visit_fn_const(
const void *storage, Visitor &v)
FL_NO_EXCEPT {
311
312
314 v.accept(*typed_ptr);
315 }
316
317
318
319
325 };
327 table[_tag - 1](&_storage);
328 }
330 }
331
332
333
334 void copy_construct_from(
const variant &other)
FL_NO_EXCEPT {
339 };
340 table[other._tag - 1](&_storage, &other._storage[0]);
342 _tag = other._tag;
343 }
344
345
346
352 };
353 table[other._tag - 1](&_storage, &other._storage[0]);
355 _tag = other._tag;
356 other.reset();
357 }
358
359
360
361
362
363
364
365
366 template <
typename T>
static constexpr Tag type_to_tag()
FL_NO_EXCEPT {
367 return type_to_tag_impl<T, Types...>
::value;
368 }
369
370
371 template <typename T, typename... Ts> struct type_to_tag_impl;
372
373 template <typename T> struct type_to_tag_impl<T> {
374 static constexpr Tag value = 0;
375 };
376
377 template <typename T, typename U, typename... Rest>
378 struct type_to_tag_impl<T, U, Rest...> {
379 static constexpr Tag value =
381 ? 1
382 : (type_to_tag_impl<T, Rest...>::value == 0
383 ? 0
384 : type_to_tag_impl<T, Rest...>::value + 1);
385 };
386
387 template <
typename T,
typename... Args>
void construct(Args &&...
args)
FL_NO_EXCEPT {
389 _tag = type_to_tag<T>();
390 }
391
393
394 Tag _tag;
395};
A fixed-size array implementation similar to std::array.
#define FL_DISABLE_WARNING(warning)
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
void(*)(void *) variant_destroy_fn
constexpr variant_destroy_fn pick_variant_destroy_fn() FL_NO_EXCEPT
constexpr variant_copy_fn pick_variant_copy_fn() FL_NO_EXCEPT
void(*)(void *, void *) variant_move_fn
constexpr variant_move_fn pick_variant_move_fn() FL_NO_EXCEPT
void(*)(void *, const void *) variant_copy_fn
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
constexpr int type_rank< T >::value
constexpr T && forward(typename remove_reference< T >::type &t) FL_NO_EXCEPT
InputGamut g FL_NO_EXCEPT
pair_element< I, T1, T2 >::type & get(pair< T1, T2 > &p) FL_NO_EXCEPT
To * bit_cast_ptr(void *storage) FL_NO_EXCEPT
#define FL_ALIGN_AS_T(expr)