{{ message }}
Repository navigation
Expand file tree
/
Copy pathvariant.hpp
More file actions
628 lines (628 loc) · 27.7 KB
/
Copy pathvariant.hpp
File metadata and controls
628 lines (628 loc) · 27.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
#pragma once
#include<type_traits>
#include<algorithm>
#include<ranges>
#include<vector>
#include<string>
#include<cmath>
#ifndef __INTELLISENSE__
#include<meta>
#endif
#include<new>
#include"concepts.hpp"
#include"launder.hpp"
#include"assert.hpp"
#include"trap.hpp"
#include"eto.hpp"
#include"rtl.hpp"
#ifdef __INTELLISENSE__
namespace cppp{
struct uninitialize_t{} constexpr inline uninitialize;
template<enumeration auto v>
struct in_place_etor_t{};
template<enumeration auto v>
constexpr inline in_place_etor_t<v> in_place_etor;
template<enumeration E>
class variant{
public:
template<E v>
using lookup = __error_type;
variant() noexcept;
variant(uninitialize_t) noexcept;
template<E val,typename ...A>
variant(in_place_etor_t<val>,A&& ...a);
variant(const variant& other);
variant(variant&& other);
variant& operator=(const variant& other);
variant& operator=(variant&& other);
explicit operator bool();
E tag() const noexcept;
template<E val,typename ...A>
__error_type initialize(A&& ...a);
template<E val,typename ...A>
__error_type emplace(A&& ...a);
template<E val>
const __error_type& get() const noexcept;
template<E val>
__error_type& get() noexcept;
template<typename Fn>
__error_type visit(Fn&& fn);
template<typename Fn>
__error_type visit(Fn&& fn) const;
~variant();
};
template<enumeration E>
class heap_variant{
public:
template<E v>
using lookup = __error_type;
constexpr heap_variant() noexcept;
constexpr heap_variant(uninitialize_t) noexcept;
template<E val,typename ...A>
constexpr heap_variant(in_place_etor_t<val>,A&& ...a);
constexpr heap_variant(const heap_variant& other);
constexpr heap_variant(heap_variant&& other);
constexpr heap_variant& operator=(const heap_variant& other);
constexpr heap_variant& operator=(heap_variant&& other);
constexpr explicit operator bool();
constexpr E tag() const noexcept;
template<E val,typename ...A>
constexpr __error_type initialize(A&& ...a);
template<E val,typename ...A>
constexpr __error_type emplace(A&& ...a);
template<E val>
constexpr const __error_type& get() const noexcept;
template<E val>
constexpr __error_type& get() noexcept;
template<typename Fn>
constexpr __error_type visit(Fn&& fn);
template<typename Fn>
constexpr __error_type visit(Fn&& fn) const;
constexpr ~heap_variant();
};
}
#else
namespace cppp{
namespace detail{
struct etor_annot{
std::meta::info type;
};
consteval std::meta::info etor_type(std::meta::info etor){
using namespace std::literals;
if(std::vector<std::meta::info> etor_annots{annotations_of_with_type(etor,^^etor_annot)};!etor_annots.empty()){
if(etor_annots.size() > 1uz) throw std::meta::exception(u8"cppp::variant: enumerator has more than one annotation"sv,etor);
return extract<etor_annot>(etor_annots.front()).type;
}else{
std::vector<std::meta::info> annots{annotations_of(etor)};
if(annots.empty()) return ^^void;
if(annots.size() == 1uz && type_of(annots.front()) == dealias(^^std::meta::info) && is_type(extract<std::meta::info>(annots.front()))){
// GCC, you should know better than to complain that NRVO is not done on a std::meta::info instance...
// I know we can just copy it manually, but let's do the Right Thing and follow https://marralesfios.github.io/blog/nrvo
return [&annots,etor]consteval{
std::meta::info type = extract<std::meta::info>(annots.front());
if(is_lvalue_reference_type(type) || is_rvalue_reference_type(type)){
throw std::meta::exception(u8"cppp::variant: enumerator type must not be a reference type"sv,etor);
}
if(is_function_type(type)){
throw std::meta::exception(u8"cppp::variant: enumerator type must not be a function"sv,etor);
}
return type;
}();
}else throw std::meta::exception(u8"cppp::variant: enumerator does not have an unambiguous type annotation"sv,etor);
}
}
template<std::size_t n>
struct store_value{
constexpr static std::size_t value = n;
};
template<bool b>
struct store_flag{
constexpr static bool value = b;
};
template<typename E>
struct etor_info{
E v;
std::meta::info t;
};
template<typename E,etor_info<E> ...etor_infos>
class enum_info_base{
public:
constexpr static std::array<etor_info<E>,sizeof...(etor_infos)> infos{etor_infos...};
private:
template<E v>
struct _lookup;
consteval{
using namespace std::literals;
for(std::size_t i=0uz;i<infos.size();++i){
define_aggregate(substitute(^^_lookup,{std::meta::reflect_constant(infos[i].v)}),{data_member_spec(substitute(^^store_value,{std::meta::reflect_constant(i)}),{.name=u8"_tag"sv})});
}
}
template<E v>
constexpr static std::size_t member_lookup = decltype(_lookup<v>::_tag)::value;
public:
template<E v>
using lookup = [:infos[member_lookup<v>].t:];
template<E v>
constexpr static std::meta::info lookup_member = infos[member_lookup<v>].mem;
consteval static bool is_nothrow_copy_constructible() noexcept{
for(const detail::etor_info<E>& ei : infos){
if(!is_nothrow_copy_constructible_type(ei.t)) return false;
}
return true;
}
consteval static bool is_nothrow_move_constructible() noexcept{
for(const detail::etor_info<E>& ei : infos){
if(!is_nothrow_move_constructible_type(ei.t)) return false;
}
return true;
}
constexpr static bool is_optional = is_void_type(infos[0uz].t);
consteval static bool is_nothrow_copy_assignable() noexcept{
if(!is_optional) return true;
if(!is_nothrow_copy_constructible()) return false;
for(const detail::etor_info<E>& ei : infos){
if(!is_nothrow_copy_assignable_type(ei.t)) return false;
}
return true;
}
consteval static bool is_nothrow_move_assignable() noexcept{
if(!is_optional) return true;
if(!is_nothrow_move_constructible()) return false;
for(const detail::etor_info<E>& ei : infos){
if(!is_nothrow_move_assignable_type(ei.t)) return false;
}
return true;
}
};
template<typename E,std::size_t s,std::size_t a,etor_info<E> ...etor_infos>
class inplace_enum_info_base : public enum_info_base<E,etor_infos...>{
public:
constexpr static std::size_t size = s;
constexpr static std::size_t alignment = a;
};
template<enumeration E>
using enum_info = [:[]consteval static{
std::vector<std::meta::info> etor_infos{^^E};
for(std::meta::info etor : enumerators_of(^^E)){
std::meta::info t = etor_type(etor);
etor_infos.emplace_back(std::meta::reflect_constant(etor_info<E>{.v=extract<E>(etor),.t=t}));
}
return substitute(^^enum_info_base,etor_infos);
}():];
template<enumeration E>
using inplace_enum_info = [:[]consteval static{
std::vector<std::meta::info> etor_infos;
std::size_t size = 0uz;
std::size_t alignment = 1uz;
for(std::meta::info etor : enumerators_of(^^E)){
std::meta::info t = etor_type(etor);
etor_infos.emplace_back(std::meta::reflect_constant(etor_info<E>{.v=extract<E>(etor),.t=t}));
if(!is_void_type(t)){
size = std::max(size,size_of(t));
alignment = std::max(alignment,alignment_of(t));
}
}
return substitute(^^inplace_enum_info_base,std::views::concat(rtl<std::initializer_list<std::meta::info>>({^^E,std::meta::reflect_constant(size),std::meta::reflect_constant(alignment)}),etor_infos));
}():];
struct inplace_destroy{
constexpr static void operator()() noexcept{}
template<typename T>
constexpr static void operator()(T& v) noexcept(std::is_nothrow_destructible_v<T>){
v.~T();
}
};
}
template<typename T>
constexpr inline detail::etor_annot etor{.type = ^^T};
struct uninitialize_t{} constexpr inline uninitialize;
template<enumeration auto v>
struct in_place_etor_t{};
template<enumeration auto v>
constexpr inline in_place_etor_t<v> in_place_etor;
template<enumeration E>
class variant{
#if __cpp_consteval >= 202406L
#warning P4101 might be merged! Check to see if access_constexpr_etor is still necessary.
#endif
// At least before P4101, etor_info<E> being a consteval-only type makes accessing infos[...].v promote the entire containing function to consteval. This is unacceptable.
template<E v>
constexpr static E access_constexpr_etor = v;
using info_t = detail::inplace_enum_info<E>;
[[no_unique_address]] potentially_empty_array<std::byte,info_t::size,info_t::alignment> data;
E _tag;
template<typename T>
T& _get() noexcept{
return read_object<T>(data.data());
}
template<typename T>
const T& _get() const noexcept{
return read_object<T>(data.data());
}
void _destroy() noexcept{
visit(detail::inplace_destroy());
}
template<typename T,typename ...A>
T& emplace_construct(A&& ...a) noexcept(std::is_nothrow_constructible_v<T,A...>){
return *new(data.data()) T(std::forward<A>(a)...);
}
template<typename T,typename ...A>
T& _emplace(A&& ...a) noexcept(!info_t::is_optional || std::is_nothrow_constructible_v<T,A...>){
_destroy();
if constexpr(info_t::is_optional && !std::is_nothrow_constructible_v<T,A...>){
try{
return emplace_construct<T>(std::forward<A>(a)...);
}catch(...){
_tag = access_constexpr_etor<info_t::infos[0uz].v>;
throw;
}
}else{
return emplace_construct<T>(std::forward<A>(a)...);
}
}
public:
template<E v>
using lookup = info_t::template lookup<v>;
variant() noexcept requires(info_t::is_optional) : _tag(access_constexpr_etor<info_t::infos[0uz].v>){}
variant(uninitialize_t) noexcept{}
template<E val,typename ...A> requires(!std::is_void_v<lookup<val>>)
variant(in_place_etor_t<val>,A&& ...a) noexcept(noexcept(new(data.data()) lookup<val>(std::forward<A>(a)...))) : _tag(val){
emplace_construct<lookup<val>>(std::forward<A>(a)...);
}
template<E val> requires(std::is_void_v<lookup<val>>)
variant(in_place_etor_t<val>) noexcept : _tag(val){}
variant(const variant& other) noexcept(info_t::is_nothrow_copy_constructible()) : _tag(other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
emplace_construct<typename[:ei.t:]>(other._get<typename[:ei.t:]>());
}
}
}
}
variant(variant&& other) noexcept(info_t::is_nothrow_move_constructible()) : _tag(other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
emplace_construct<typename[:ei.t:]>(std::move(other._get<typename[:ei.t:]>()));
}
}
}
}
variant& operator=(const variant& other) noexcept(info_t::is_nothrow_copy_assignable()){
if(_tag == other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
_get<typename[:ei.t:]>() = other._get<typename[:ei.t:]>();
}
}
}
}else{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == other._tag){
_emplace<typename[:ei.t:]>(other._get<typename[:ei.t:]>());
}
}
}
_tag = other._tag;
}
return *this;
}
variant& operator=(variant&& other) noexcept(info_t::is_nothrow_move_assignable()){
if(_tag == other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
_get<typename[:ei.t:]>() = std::move(other._get<typename[:ei.t:]>());
}
}
}
}else{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == other._tag){
_emplace<typename[:ei.t:]>(std::move(other._get<typename[:ei.t:]>()));
}
}
}
_tag = other._tag;
}
return *this;
}
explicit operator bool() requires(info_t::is_optional){
return _tag != access_constexpr_etor<info_t::infos[0uz].v>;
}
E tag() const noexcept{
return _tag;
}
template<E val,typename ...A>
lookup<val>& initialize(A&& ...a) noexcept(std::is_nothrow_constructible_v<lookup<val>,A...>){
lookup<val>& ref = emplace_construct<lookup<val>>(std::forward<A>(a)...);
_tag = val;
return ref;
}
template<E val>
void initialize() noexcept requires(std::is_void_v<lookup<val>>){
_tag = val;
}
template<E val,typename ...A>
lookup<val>& emplace(A&& ...a) noexcept(!info_t::is_optional || std::is_nothrow_constructible_v<lookup<val>,A...>){
lookup<val>& ref = _emplace<lookup<val>>(std::forward<A>(a)...);
_tag = val;
return ref;
}
template<E val>
void emplace() noexcept requires(std::is_void_v<lookup<val>>){
_destroy();
_tag = val;
}
template<E val>
const lookup<val>& get() const noexcept{
CPPP_ASSERT(_tag == val);
return _get<lookup<val>>();
}
template<E val>
lookup<val>& get() noexcept{
CPPP_ASSERT(_tag == val);
return _get<lookup<val>>();
}
template<typename Fn>
decltype(auto) visit(Fn&& fn){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if(ei.v == _tag){
if constexpr(is_void_type(ei.t)){
return std::forward<Fn>(fn)();
}else{
return std::forward<Fn>(fn)(_get<typename[:ei.t:]>());
}
}
}
unreachable();
}
template<typename Fn>
decltype(auto) visit(Fn&& fn) const{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if(ei.v == _tag){
if constexpr(is_void_type(ei.t)){
return std::forward<Fn>(fn)();
}else{
return std::forward<Fn>(fn)(_get<typename[:ei.t:]>());
}
}
}
unreachable();
}
~variant(){
_destroy();
}
};
namespace detail{
template<typename T>
concept eligible_for_soo = sizeof(T) <= sizeof(void*) && alignof(T) <= alignof(void*);
}
template<enumeration E>
class heap_variant{
#if __cpp_consteval >= 202406L
#warning P4101 might be merged! Check to see if access_constexpr_etor is still necessary.
#endif
// At least before P4101, etor_info<E> being a consteval-only type makes accessing infos[...].v promote the entire containing function to consteval. This is unacceptable.
template<E v>
constexpr static E access_constexpr_etor = v;
using info_t = detail::enum_info<E>;
alignas(void*) std::byte data[sizeof(void*)];
E _tag;
template<typename T>
constexpr T& _get() noexcept{
if constexpr(detail::eligible_for_soo<T>){
return read_object<T>(data);
}else{
return *static_cast<T*>(read_object<void*>(data));
}
}
template<typename T>
constexpr const T& _get() const noexcept{
if constexpr(detail::eligible_for_soo<T>){
return read_object<T>(data);
}else{
return *static_cast<const T*>(read_object<void*>(data));
}
}
constexpr void _destroy() noexcept{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if(ei.v == _tag){
if constexpr(!is_void_type(ei.t)){
typename[:ei.t:]* ptr = &_get<typename[:ei.t:]>();
if constexpr(detail::eligible_for_soo<typename[:ei.t:]>){
std::destroy_at(ptr);
}else{
delete ptr;
std::destroy_at(&read_object<void*>(data));
}
}
}
}
}
template<typename T,typename ...A>
constexpr T& emplace_construct(A&& ...a) noexcept(std::is_nothrow_constructible_v<T,A...>){
if constexpr(detail::eligible_for_soo<T>){
return *new(data) T(std::forward<A>(a)...);
}else{
using voidp = void*;
T* p;
new(data) voidp(p = new T(std::forward<A>(a)...));
return *p;
}
}
template<typename T,typename ...A>
constexpr T& _emplace(A&& ...a) noexcept(std::is_nothrow_constructible_v<T,A...> || (detail::eligible_for_soo<T> && !info_t::is_optional)){
if constexpr(detail::eligible_for_soo<T>){
_destroy();
if constexpr(info_t::is_optional && !std::is_nothrow_constructible_v<T,A...>){
try{
return *new(data) T(std::forward<A>(a)...);
}catch(...){
_tag = access_constexpr_etor<info_t::infos[0uz].v>;
throw;
}
}else{
return *new(data) T(std::forward<A>(a)...);
}
}else{
T* alloc = new T(std::forward<A>(a)...);
_destroy();
using voidp = void*;
new(data) voidp(alloc);
return *alloc;
}
}
public:
template<E v>
using lookup = info_t::template lookup<v>;
constexpr heap_variant() noexcept requires(info_t::is_optional) : data{}, _tag(access_constexpr_etor<info_t::infos[0uz].v>){}
constexpr heap_variant(uninitialize_t) noexcept{}
template<E val,typename ...A> requires(!std::is_void_v<lookup<val>>)
constexpr heap_variant(in_place_etor_t<val>,A&& ...a) : data{}, _tag(val){
emplace_construct<lookup<val>>(std::forward<A>(a)...);
}
template<E val> requires(std::is_void_v<lookup<val>>)
constexpr heap_variant(in_place_etor_t<val>) noexcept : data{}, _tag(val){}
constexpr heap_variant(const heap_variant& other) noexcept(info_t::is_nothrow_copy_constructible()) : data{}, _tag(other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
emplace_construct<typename[:ei.t:]>(other._get<typename[:ei.t:]>());
}
}
}
}
constexpr heap_variant(heap_variant&& other) noexcept(info_t::is_nothrow_move_constructible()) : data{}, _tag(other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
emplace_construct<typename[:ei.t:]>(std::move(other._get<typename[:ei.t:]>()));
}
}
}
}
// TODO: revise noexcept specification
constexpr heap_variant& operator=(const heap_variant& other){
if(_tag == other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == _tag){
_get<typename[:ei.t:]>() = other._get<typename[:ei.t:]>();
}
}
}
}else{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == other._tag){
_emplace<typename[:ei.t:]>(other._get<typename[:ei.t:]>());
}
}
}
_tag = other._tag;
}
return *this;
}
// TODO: revise noexcept specification
constexpr heap_variant& operator=(heap_variant&& other){
if(_tag == other._tag){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if(ei.v == _tag){
if constexpr(!is_void_type(ei.t)){
_get<typename[:ei.t:]>() = std::move(other._get<typename[:ei.t:]>());
}
}
}
}else{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if constexpr(!is_void_type(ei.t)){
if(ei.v == other._tag){
_emplace<typename[:ei.t:]>(std::move(other._get<typename[:ei.t:]>()));
}
}
}
_tag = other._tag;
}
return *this;
}
constexpr explicit operator bool() requires(info_t::is_optional){
return _tag != access_constexpr_etor<info_t::infos[0uz].v>;
}
constexpr E tag() const noexcept{
return _tag;
}
template<E val,typename ...A>
constexpr lookup<val>& initialize(A&& ...a) noexcept(std::is_nothrow_constructible_v<lookup<val>,A...>){
lookup<val>& ref = emplace_construct<lookup<val>>(std::forward<A>(a)...);
_tag = val;
return ref;
}
template<E val>
constexpr void initialize() noexcept requires(std::is_void_v<lookup<val>>){
_tag = val;
}
template<E val,typename ...A>
constexpr lookup<val>& emplace(A&& ...a) noexcept(std::is_nothrow_constructible_v<lookup<val>,A...> || (detail::eligible_for_soo<lookup<val>> && !info_t::is_optional)){
lookup<val>& ref = _emplace<lookup<val>>(std::forward<A>(a)...);
_tag = val;
return ref;
}
template<E val>
constexpr void emplace() noexcept requires(std::is_void_v<lookup<val>>){
_destroy();
_tag = val;
}
template<E val>
constexpr const lookup<val>& get() const noexcept{
if consteval{
cppp::consteval_assert(_tag == val);
}else{
CPPP_ASSERT(_tag == val);
}
return _get<lookup<val>>();
}
template<E val>
constexpr lookup<val>& get() noexcept{
if consteval{
cppp::consteval_assert(_tag == val);
}else{
CPPP_ASSERT(_tag == val);
}
return _get<lookup<val>>();
}
template<typename Fn>
constexpr decltype(auto) visit(Fn&& fn){
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if(ei.v == _tag){
if constexpr(is_void_type(ei.t)){
return std::forward<Fn>(fn)();
}else{
return std::forward<Fn>(fn)(_get<typename[:ei.t:]>());
}
}
}
unreachable();
}
template<typename Fn>
constexpr decltype(auto) visit(Fn&& fn) const{
template for(constexpr const detail::etor_info<E>& ei : info_t::infos){
if(ei.v == _tag){
if constexpr(is_void_type(ei.t)){
return std::forward<Fn>(fn)();
}else{
return std::forward<Fn>(fn)(_get<typename[:ei.t:]>());
}
}
}
unreachable();
}
constexpr ~heap_variant(){
_destroy();
}
};
}
#endif
You can’t perform that action at this time.
