-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreference_interface_protocol.h
More file actions
854 lines (685 loc) · 28.6 KB
/
reference_interface_protocol.h
File metadata and controls
854 lines (685 loc) · 28.6 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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
// ============================================================================
// AUTOMATICALLY GENERATED FILE - DO NOT MODIFY
// ============================================================================
// This file was generated by scripts/generate_protocol.py
// from interface file: reference_interface.h
// for protocol interface: ReferenceInterface
//
// Any manual changes made to this file will be overwritten during the next
// build or code generation run.
// ============================================================================
#include <cassert>
#include <concepts>
#include <cstddef>
#include <initializer_list>
#include <memory>
#include <type_traits>
#include <utility>
#include "protocol.h"
#include "reference_interface.h"
namespace xyz {
template <typename T>
concept protocol_const_concept_ReferenceInterface = requires(const T& t) {
{ t.get_value() } -> std::convertible_to<int>;
{ t.overloaded(std::declval<int>()) };
{ t.overloaded(std::declval<std::string_view>()) };
{
t.operator()(std::declval<int>(), std::declval<int>())
} -> std::convertible_to<int>;
};
template <typename T>
concept protocol_concept_ReferenceInterface =
protocol_const_concept_ReferenceInterface<T> && requires(T& t) {
{ t.update(std::declval<const ReferencePoint&>(), std::declval<int*>()) };
{
t.compute(std::declval<double>())
} noexcept -> std::convertible_to<double>;
{ t.overloaded(std::declval<int>()) };
{ t.operator+=(std::declval<int>()) };
{ t.operator[](std::declval<std::size_t>()) } -> std::convertible_to<int>;
};
struct const_view_vtable_ReferenceInterface {
int (*get_value_51992268)(const void* ptr);
void (*overloaded_c1840915)(const void* ptr, int);
void (*overloaded_910a8c34)(const void* ptr, std::string_view);
int (*__operator__call___464ad6f1)(const void* ptr, int, int);
};
template <typename T>
inline constexpr const_view_vtable_ReferenceInterface
const_view_vtable_ReferenceInterface_for = {
[](const void* ptr) -> int {
return static_cast<const T*>(ptr)->get_value();
},
[](const void* ptr, int a0) -> void {
static_cast<const T*>(ptr)->overloaded(
std::forward<decltype(a0)>(a0));
},
[](const void* ptr, std::string_view a0) -> void {
static_cast<const T*>(ptr)->overloaded(
std::forward<decltype(a0)>(a0));
},
[](const void* ptr, int a0, int a1) -> int {
return static_cast<const T*>(ptr)->operator()(
std::forward<decltype(a0)>(a0), std::forward<decltype(a1)>(a1));
}
};
struct view_vtable_ReferenceInterface {
const_view_vtable_ReferenceInterface const_view;
void (*update_beb1c984)(void* ptr, const ReferencePoint&, int*);
double (*compute_8e9404f6)(void* ptr, double) noexcept;
void (*overloaded_20eb843b)(void* ptr, int);
void (*__operator__plus_equal___c2d56e3d)(void* ptr, int);
int (*__operator__subscript___1a581dd4)(void* ptr, std::size_t);
};
template <typename T>
inline constexpr view_vtable_ReferenceInterface
view_vtable_ReferenceInterface_for = {
const_view_vtable_ReferenceInterface_for<T>,
[](void* ptr, const ReferencePoint& a0, int* a1) -> void {
static_cast<T*>(ptr)->update(std::forward<decltype(a0)>(a0),
std::forward<decltype(a1)>(a1));
},
[](void* ptr, double a0) noexcept -> double {
return static_cast<T*>(ptr)->compute(std::forward<decltype(a0)>(a0));
},
[](void* ptr, int a0) -> void {
static_cast<T*>(ptr)->overloaded(std::forward<decltype(a0)>(a0));
},
[](void* ptr, int a0) -> void {
static_cast<T*>(ptr)->operator+=(std::forward<decltype(a0)>(a0));
},
[](void* ptr, std::size_t a0) -> int {
return static_cast<T*>(ptr)->operator[](
std::forward<decltype(a0)>(a0));
}
};
template <>
struct protocol_vtable_traits<::xyz::ReferenceInterface> {
using const_vtable = const_view_vtable_ReferenceInterface;
using vtable = view_vtable_ReferenceInterface;
};
template <typename Allocator>
struct protocol_owning_vtable_traits<::xyz::ReferenceInterface, Allocator> {
using vtable =
typename protocol<::xyz::ReferenceInterface, Allocator>::vtable;
};
template <typename From>
inline void map_vtable_members(const From* from,
const_view_vtable_ReferenceInterface* to) {
to->get_value_51992268 = from->get_value_51992268;
to->overloaded_c1840915 = from->overloaded_c1840915;
to->overloaded_910a8c34 = from->overloaded_910a8c34;
to->__operator__call___464ad6f1 = from->__operator__call___464ad6f1;
}
template <typename From>
inline void map_mutable_vtable_members(const From* from,
view_vtable_ReferenceInterface* to) {
to->const_view.get_value_51992268 = from->const_view.get_value_51992268;
to->const_view.overloaded_c1840915 = from->const_view.overloaded_c1840915;
to->const_view.overloaded_910a8c34 = from->const_view.overloaded_910a8c34;
to->const_view.__operator__call___464ad6f1 =
from->const_view.__operator__call___464ad6f1;
to->update_beb1c984 = from->update_beb1c984;
to->compute_8e9404f6 = from->compute_8e9404f6;
to->overloaded_20eb843b = from->overloaded_20eb843b;
to->__operator__plus_equal___c2d56e3d =
from->__operator__plus_equal___c2d56e3d;
to->__operator__subscript___1a581dd4 = from->__operator__subscript___1a581dd4;
}
template <typename From>
inline void map_owning_vtable_members(
const From* from,
typename protocol_owning_vtable_traits<
::xyz::ReferenceInterface, typename From::allocator_type>::vtable* to) {
to->xyz_protocol_clone = from->xyz_protocol_clone;
to->xyz_protocol_move = from->xyz_protocol_move;
to->xyz_protocol_destroy = from->xyz_protocol_destroy;
to->view_vt = get_mutable_vtable<typename From::protocol_type,
::xyz::ReferenceInterface>(from->view_vt);
to->get_value_51992268 = from->get_value_51992268;
to->update_beb1c984 = from->update_beb1c984;
to->compute_8e9404f6 = from->compute_8e9404f6;
to->overloaded_20eb843b = from->overloaded_20eb843b;
to->overloaded_c1840915 = from->overloaded_c1840915;
to->overloaded_910a8c34 = from->overloaded_910a8c34;
to->__operator__plus_equal___c2d56e3d =
from->__operator__plus_equal___c2d56e3d;
to->__operator__call___464ad6f1 = from->__operator__call___464ad6f1;
to->__operator__subscript___1a581dd4 = from->__operator__subscript___1a581dd4;
}
template <typename Allocator>
class protocol<::xyz::ReferenceInterface, Allocator> {
friend class protocol_view<::xyz::ReferenceInterface>;
friend class protocol_view<const ::xyz::ReferenceInterface>;
template <typename, typename>
friend class protocol;
template <typename, typename>
friend struct protocol_owning_vtable_traits;
struct vtable {
using protocol_type = ::xyz::ReferenceInterface;
using allocator_type = Allocator;
void* (*xyz_protocol_clone)(void* cb, const Allocator& alloc);
void* (*xyz_protocol_move)(void* cb, const Allocator& alloc);
void (*xyz_protocol_destroy)(void* cb, const Allocator& alloc);
const view_vtable_ReferenceInterface* view_vt;
int (*get_value_51992268)(void* cb);
void (*update_beb1c984)(void* cb, const ReferencePoint&, int*);
double (*compute_8e9404f6)(void* cb, double) noexcept;
void (*overloaded_20eb843b)(void* cb, int);
void (*overloaded_c1840915)(void* cb, int);
void (*overloaded_910a8c34)(void* cb, std::string_view);
void (*__operator__plus_equal___c2d56e3d)(void* cb, int);
int (*__operator__call___464ad6f1)(void* cb, int, int);
int (*__operator__subscript___1a581dd4)(void* cb, std::size_t);
};
template <typename T>
struct vtable_impl {
using t_allocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<T>;
using t_alloc_traits = std::allocator_traits<t_allocator>;
static void* xyz_protocol_clone(void* cb, const Allocator& alloc) {
auto* self = static_cast<T*>(cb);
t_allocator t_alloc(alloc);
auto mem = t_alloc_traits::allocate(t_alloc, 1);
try {
t_alloc_traits::construct(t_alloc, mem, *self);
return mem;
} catch (...) {
t_alloc_traits::deallocate(t_alloc, mem, 1);
throw;
}
}
static void* xyz_protocol_move(void* cb, const Allocator& alloc) {
auto* self = static_cast<T*>(cb);
t_allocator t_alloc(alloc);
auto mem = t_alloc_traits::allocate(t_alloc, 1);
try {
t_alloc_traits::construct(t_alloc, mem, std::move(*self));
return mem;
} catch (...) {
t_alloc_traits::deallocate(t_alloc, mem, 1);
throw;
}
}
static void xyz_protocol_destroy(void* cb, const Allocator& alloc) {
auto* self = static_cast<T*>(cb);
t_allocator t_alloc(alloc);
t_alloc_traits::destroy(t_alloc, self);
t_alloc_traits::deallocate(t_alloc, self, 1);
}
static int get_value_51992268(void* cb) {
auto* self = static_cast<T*>(cb);
return self->get_value();
}
static void update_beb1c984(void* cb, const ReferencePoint& a0, int* a1) {
auto* self = static_cast<T*>(cb);
self->update(std::forward<decltype(a0)>(a0),
std::forward<decltype(a1)>(a1));
}
static double compute_8e9404f6(void* cb, double a0) noexcept {
auto* self = static_cast<T*>(cb);
return self->compute(std::forward<decltype(a0)>(a0));
}
static void overloaded_20eb843b(void* cb, int a0) {
auto* self = static_cast<T*>(cb);
self->overloaded(std::forward<decltype(a0)>(a0));
}
static void overloaded_c1840915(void* cb, int a0) {
auto* self = static_cast<T*>(cb);
self->overloaded(std::forward<decltype(a0)>(a0));
}
static void overloaded_910a8c34(void* cb, std::string_view a0) {
auto* self = static_cast<T*>(cb);
self->overloaded(std::forward<decltype(a0)>(a0));
}
static void __operator__plus_equal___c2d56e3d(void* cb, int a0) {
auto* self = static_cast<T*>(cb);
self->operator+=(std::forward<decltype(a0)>(a0));
}
static int __operator__call___464ad6f1(void* cb, int a0, int a1) {
auto* self = static_cast<T*>(cb);
return self->operator()(std::forward<decltype(a0)>(a0),
std::forward<decltype(a1)>(a1));
}
static int __operator__subscript___1a581dd4(void* cb, std::size_t a0) {
auto* self = static_cast<T*>(cb);
return self->operator[](std::forward<decltype(a0)>(a0));
}
static constexpr vtable vtable_ = {xyz_protocol_clone,
xyz_protocol_move,
xyz_protocol_destroy,
&view_vtable_ReferenceInterface_for<T>,
get_value_51992268,
update_beb1c984,
compute_8e9404f6,
overloaded_20eb843b,
overloaded_c1840915,
overloaded_910a8c34,
__operator__plus_equal___c2d56e3d,
__operator__call___464ad6f1,
__operator__subscript___1a581dd4
};
};
using allocator_traits = std::allocator_traits<Allocator>;
template <class U, class... Ts>
[[nodiscard]] constexpr void* create_storage(Ts&&... ts) const {
using t_allocator =
typename std::allocator_traits<Allocator>::template rebind_alloc<U>;
t_allocator t_alloc(alloc_);
using t_alloc_traits = std::allocator_traits<t_allocator>;
auto mem = t_alloc_traits::allocate(t_alloc, 1);
try {
t_alloc_traits::construct(t_alloc, mem, std::forward<Ts>(ts)...);
return mem;
} catch (...) {
t_alloc_traits::deallocate(t_alloc, mem, 1);
throw;
}
}
void* p_;
const vtable* vtable_;
[[no_unique_address]] Allocator alloc_;
public:
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
constexpr protocol(protocol<Other, Allocator>&& other) noexcept(
allocator_traits::is_always_equal::value)
: alloc_(other.alloc_) {
if (alloc_ == other.alloc_) {
p_ = std::exchange(other.p_, nullptr);
vtable_ = get_owning_vtable<Other, ::xyz::ReferenceInterface, Allocator>(
std::exchange(other.vtable_, nullptr));
} else {
if (!other.valueless_after_move()) {
p_ = other.vtable_->xyz_protocol_move(other.p_, alloc_);
vtable_ =
get_owning_vtable<Other, ::xyz::ReferenceInterface, Allocator>(
other.vtable_);
other.vtable_->xyz_protocol_destroy(other.p_, other.alloc_);
other.p_ = nullptr;
other.vtable_ = nullptr;
} else {
p_ = nullptr;
vtable_ = nullptr;
}
}
}
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
constexpr protocol(const protocol<Other, Allocator>& other)
: alloc_(allocator_traits::select_on_container_copy_construction(
other.alloc_)) {
if (!other.valueless_after_move()) {
p_ = other.vtable_->xyz_protocol_clone(other.p_, alloc_);
vtable_ = get_owning_vtable<Other, ::xyz::ReferenceInterface, Allocator>(
other.vtable_);
} else {
p_ = nullptr;
vtable_ = nullptr;
}
}
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
constexpr protocol(std::allocator_arg_t, const Allocator& alloc,
const protocol<Other, Allocator>& other)
: alloc_(alloc) {
if (!other.valueless_after_move()) {
p_ = other.vtable_->xyz_protocol_clone(other.p_, alloc_);
vtable_ = get_owning_vtable<Other, ::xyz::ReferenceInterface, Allocator>(
other.vtable_);
} else {
p_ = nullptr;
vtable_ = nullptr;
}
}
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
constexpr protocol(
std::allocator_arg_t, const Allocator& alloc,
protocol<Other, Allocator>&&
other) noexcept(allocator_traits::is_always_equal::value)
: alloc_(alloc) {
if (alloc_ == other.alloc_) {
p_ = std::exchange(other.p_, nullptr);
vtable_ = get_owning_vtable<Other, ::xyz::ReferenceInterface, Allocator>(
std::exchange(other.vtable_, nullptr));
} else {
if (!other.valueless_after_move()) {
p_ = other.vtable_->xyz_protocol_move(other.p_, alloc_);
vtable_ =
get_owning_vtable<Other, ::xyz::ReferenceInterface, Allocator>(
other.vtable_);
other.vtable_->xyz_protocol_destroy(other.p_, other.alloc_);
other.p_ = nullptr;
other.vtable_ = nullptr;
} else {
p_ = nullptr;
vtable_ = nullptr;
}
}
}
explicit constexpr protocol()
requires std::default_initializable<::xyz::ReferenceInterface> &&
protocol_concept_ReferenceInterface<::xyz::ReferenceInterface> &&
std::copy_constructible<::xyz::ReferenceInterface>
: protocol(std::allocator_arg_t{}, Allocator{}) {}
template <class U>
constexpr explicit protocol(U&& u)
requires(!std::same_as<protocol, std::remove_cvref_t<U>>) &&
not_protocol_or_view<U> &&
std::copy_constructible<std::remove_cvref_t<U>> &&
protocol_concept_ReferenceInterface<U>
: protocol(std::allocator_arg_t{}, Allocator{}, std::forward<U>(u)) {}
template <class U, class... Ts>
explicit constexpr protocol(std::in_place_type_t<U>, Ts&&... ts)
requires std::same_as<std::remove_cvref_t<U>, U> &&
not_protocol_or_view<U> && std::constructible_from<U, Ts&&...> &&
std::copy_constructible<U> &&
std::default_initializable<Allocator> &&
protocol_concept_ReferenceInterface<U>
: protocol(std::allocator_arg_t{}, Allocator{}, std::in_place_type<U>,
std::forward<Ts>(ts)...) {}
template <class U, class I, class... Ts>
explicit constexpr protocol(std::in_place_type_t<U>,
std::initializer_list<I> ilist, Ts&&... ts)
requires std::same_as<std::remove_cvref_t<U>, U> &&
not_protocol_or_view<U> &&
std::constructible_from<U, std::initializer_list<I>, Ts&&...> &&
std::copy_constructible<U> &&
std::default_initializable<Allocator> &&
protocol_concept_ReferenceInterface<U>
: protocol(std::allocator_arg_t{}, Allocator{}, std::in_place_type<U>,
ilist, std::forward<Ts>(ts)...) {}
constexpr protocol(const protocol& other)
: protocol(std::allocator_arg_t{},
allocator_traits::select_on_container_copy_construction(
other.alloc_),
other) {}
constexpr protocol(protocol&& other) noexcept(
allocator_traits::is_always_equal::value)
: protocol(std::allocator_arg_t{}, other.alloc_, std::move(other)) {}
explicit constexpr protocol(std::allocator_arg_t, const Allocator& alloc)
requires std::default_initializable<::xyz::ReferenceInterface> &&
std::copy_constructible<::xyz::ReferenceInterface>
: alloc_(alloc) {
p_ = create_storage<::xyz::ReferenceInterface>();
vtable_ = &vtable_impl<::xyz::ReferenceInterface>::vtable_;
}
template <class U>
constexpr explicit protocol(std::allocator_arg_t, const Allocator& alloc,
U&& u)
requires(not std::same_as<protocol, std::remove_cvref_t<U>>) &&
not_protocol_or_view<U> &&
std::copy_constructible<std::remove_cvref_t<U>> &&
protocol_concept_ReferenceInterface<U>
: alloc_(alloc) {
p_ = create_storage<std::remove_cvref_t<U>>(std::forward<U>(u));
vtable_ = &vtable_impl<std::remove_cvref_t<U>>::vtable_;
}
template <class U, class... Ts>
explicit constexpr protocol(std::allocator_arg_t, const Allocator& alloc,
std::in_place_type_t<U>, Ts&&... ts)
requires std::same_as<std::remove_cvref_t<U>, U> &&
not_protocol_or_view<U> && std::constructible_from<U, Ts&&...> &&
std::copy_constructible<U> &&
protocol_concept_ReferenceInterface<U>
: alloc_(alloc) {
p_ = create_storage<U>(std::forward<Ts>(ts)...);
vtable_ = &vtable_impl<U>::vtable_;
}
template <class U, class I, class... Ts>
explicit constexpr protocol(std::allocator_arg_t, const Allocator& alloc,
std::in_place_type_t<U>,
std::initializer_list<I> ilist, Ts&&... ts)
requires std::same_as<std::remove_cvref_t<U>, U> &&
not_protocol_or_view<U> &&
std::constructible_from<U, std::initializer_list<I>, Ts&&...> &&
std::copy_constructible<U> &&
protocol_concept_ReferenceInterface<U>
: alloc_(alloc) {
p_ = create_storage<U>(ilist, std::forward<Ts>(ts)...);
vtable_ = &vtable_impl<U>::vtable_;
}
constexpr protocol(std::allocator_arg_t, const Allocator& alloc,
const protocol& other)
: alloc_(alloc) {
if (!other.valueless_after_move()) {
p_ = other.vtable_->xyz_protocol_clone(other.p_, alloc_);
vtable_ = other.vtable_;
} else {
p_ = nullptr;
vtable_ = nullptr;
}
}
constexpr protocol(
std::allocator_arg_t, const Allocator& alloc,
protocol&& other) noexcept(allocator_traits::is_always_equal::value)
: alloc_(alloc) {
if constexpr (allocator_traits::is_always_equal::value) {
p_ = std::exchange(other.p_, nullptr);
vtable_ = std::exchange(other.vtable_, nullptr);
} else {
if (alloc_ == other.alloc_) {
p_ = std::exchange(other.p_, nullptr);
vtable_ = std::exchange(other.vtable_, nullptr);
} else {
if (!other.valueless_after_move()) {
p_ = other.vtable_->xyz_protocol_move(other.p_, alloc_);
vtable_ = other.vtable_;
} else {
p_ = nullptr;
vtable_ = nullptr;
}
}
}
}
constexpr bool valueless_after_move() const noexcept { return p_ == nullptr; }
~protocol() {
if (p_ != nullptr) {
vtable_->xyz_protocol_destroy(p_, alloc_);
}
}
protocol& operator=(protocol other) noexcept(
allocator_traits::is_always_equal::value) {
std::swap(p_, other.p_);
std::swap(vtable_, other.vtable_);
if constexpr (!allocator_traits::is_always_equal::value) {
std::swap(alloc_, other.alloc_);
}
return *this;
}
void swap(protocol& other) noexcept(
allocator_traits::is_always_equal::value) {
std::swap(p_, other.p_);
std::swap(vtable_, other.vtable_);
if constexpr (!allocator_traits::is_always_equal::value) {
std::swap(alloc_, other.alloc_);
}
}
friend void swap(protocol& lhs, protocol& rhs) noexcept(
allocator_traits::is_always_equal::value) {
lhs.swap(rhs);
}
public:
int get_value() const { return vtable_->get_value_51992268(p_); }
void update(const ReferencePoint& a0, int* a1) {
return vtable_->update_beb1c984(p_, std::forward<decltype(a0)>(a0),
std::forward<decltype(a1)>(a1));
}
double compute(double a0) noexcept {
return vtable_->compute_8e9404f6(p_, std::forward<decltype(a0)>(a0));
}
void overloaded(int a0) {
return vtable_->overloaded_20eb843b(p_, std::forward<decltype(a0)>(a0));
}
void overloaded(int a0) const {
return vtable_->overloaded_c1840915(p_, std::forward<decltype(a0)>(a0));
}
void overloaded(std::string_view a0) const {
return vtable_->overloaded_910a8c34(p_, std::forward<decltype(a0)>(a0));
}
void operator+=(int a0) {
return vtable_->__operator__plus_equal___c2d56e3d(
p_, std::forward<decltype(a0)>(a0));
}
int operator()(int a0, int a1) const {
return vtable_->__operator__call___464ad6f1(
p_, std::forward<decltype(a0)>(a0), std::forward<decltype(a1)>(a1));
}
int operator[](std::size_t a0) {
return vtable_->__operator__subscript___1a581dd4(
p_, std::forward<decltype(a0)>(a0));
}
};
template <>
class protocol_view<const ::xyz::ReferenceInterface> {
template <typename>
friend class protocol_view;
const void* ptr_;
const const_view_vtable_ReferenceInterface* vptr_;
constexpr protocol_view(
const void* ptr,
const const_view_vtable_ReferenceInterface* vptr) noexcept
: ptr_(ptr), vptr_(vptr) {}
template <typename Alloc>
static const void* checked_ptr(
const protocol<::xyz::ReferenceInterface, Alloc>& p) noexcept {
assert(!p.valueless_after_move());
return p.p_;
}
public:
template <typename T>
requires protocol_const_concept_ReferenceInterface<T> &&
not_protocol_or_view<T>
constexpr protocol_view(const T& obj) noexcept
: ptr_(std::addressof(obj)),
vptr_(
&const_view_vtable_ReferenceInterface_for<std::remove_cvref_t<T>>) {
}
template <typename T>
requires protocol_const_concept_ReferenceInterface<T> &&
not_protocol_or_view<T>
protocol_view(const T&&) = delete;
template <typename Alloc>
protocol_view(const protocol<::xyz::ReferenceInterface, Alloc>& p) noexcept
: ptr_(checked_ptr(p)), vptr_(&p.vtable_->view_vt->const_view) {}
template <typename Alloc>
protocol_view(const protocol<::xyz::ReferenceInterface, Alloc>&&) = delete;
template <typename Alloc>
protocol_view(protocol<::xyz::ReferenceInterface, Alloc>& p) noexcept
: ptr_(checked_ptr(p)), vptr_(&p.vtable_->view_vt->const_view) {}
template <typename Alloc>
protocol_view(protocol<::xyz::ReferenceInterface, Alloc>&&) = delete;
constexpr protocol_view(
protocol_view<::xyz::ReferenceInterface> other) noexcept;
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(const protocol_view<const Other>& other) noexcept
: ptr_(other.ptr_),
vptr_(get_vtable<Other, ::xyz::ReferenceInterface>(other.vptr_)) {}
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(const protocol_view<Other>& other) noexcept
: ptr_(other.ptr_),
vptr_(get_vtable<Other, ::xyz::ReferenceInterface>(
&other.vptr_->const_view)) {}
template <typename Other, typename Alloc>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(const protocol<Other, Alloc>& p) noexcept
: protocol_view(protocol_view<const Other>(p)) {}
template <typename Other, typename Alloc>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(const protocol<Other, Alloc>&&) = delete;
template <typename Other, typename Alloc>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(protocol<Other, Alloc>& p) noexcept
: protocol_view(protocol_view<Other>(p)) {}
template <typename Other, typename Alloc>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(protocol<Other, Alloc>&&) = delete;
int get_value() const { return vptr_->get_value_51992268(ptr_); }
void overloaded(int a0) const {
vptr_->overloaded_c1840915(ptr_, std::forward<decltype(a0)>(a0));
}
void overloaded(std::string_view a0) const {
vptr_->overloaded_910a8c34(ptr_, std::forward<decltype(a0)>(a0));
}
int operator()(int a0, int a1) const {
return vptr_->__operator__call___464ad6f1(
ptr_, std::forward<decltype(a0)>(a0), std::forward<decltype(a1)>(a1));
}
};
template <>
class protocol_view<::xyz::ReferenceInterface> {
template <typename>
friend class protocol_view;
void* ptr_;
const view_vtable_ReferenceInterface* vptr_;
template <typename Alloc>
static void* checked_ptr(
protocol<::xyz::ReferenceInterface, Alloc>& p) noexcept {
assert(!p.valueless_after_move());
return p.p_;
}
public:
template <typename T>
requires protocol_concept_ReferenceInterface<T> && not_protocol_or_view<T>
constexpr protocol_view(T& obj) noexcept
: ptr_(std::addressof(obj)),
vptr_(&view_vtable_ReferenceInterface_for<std::remove_cvref_t<T>>) {}
template <typename T>
requires protocol_concept_ReferenceInterface<T> && not_protocol_or_view<T>
protocol_view(const T&&) = delete;
template <typename Alloc>
protocol_view(protocol<::xyz::ReferenceInterface, Alloc>& p) noexcept
: ptr_(checked_ptr(p)), vptr_(p.vtable_->view_vt) {}
template <typename Alloc>
protocol_view(protocol<::xyz::ReferenceInterface, Alloc>&&) = delete;
template <typename Other>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(const protocol_view<Other>& other) noexcept
: ptr_(other.ptr_),
vptr_(
get_mutable_vtable<Other, ::xyz::ReferenceInterface>(other.vptr_)) {
}
template <typename Other, typename Alloc>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(protocol<Other, Alloc>& p) noexcept
: protocol_view(protocol_view<Other>(p)) {}
template <typename Other, typename Alloc>
requires(!std::same_as<Other, ::xyz::ReferenceInterface>)
protocol_view(protocol<Other, Alloc>&&) = delete;
int get_value() const { return vptr_->const_view.get_value_51992268(ptr_); }
void update(const ReferencePoint& a0, int* a1) const {
vptr_->update_beb1c984(ptr_, std::forward<decltype(a0)>(a0),
std::forward<decltype(a1)>(a1));
}
double compute(double a0) const noexcept {
return vptr_->compute_8e9404f6(ptr_, std::forward<decltype(a0)>(a0));
}
void overloaded(int a0) const {
vptr_->overloaded_20eb843b(ptr_, std::forward<decltype(a0)>(a0));
}
void overloaded(int a0) const {
vptr_->const_view.overloaded_c1840915(ptr_, std::forward<decltype(a0)>(a0));
}
void overloaded(std::string_view a0) const {
vptr_->const_view.overloaded_910a8c34(ptr_, std::forward<decltype(a0)>(a0));
}
void operator+=(int a0) const {
vptr_->__operator__plus_equal___c2d56e3d(ptr_,
std::forward<decltype(a0)>(a0));
}
int operator()(int a0, int a1) const {
return vptr_->const_view.__operator__call___464ad6f1(
ptr_, std::forward<decltype(a0)>(a0), std::forward<decltype(a1)>(a1));
}
int operator[](std::size_t a0) const {
return vptr_->__operator__subscript___1a581dd4(
ptr_, std::forward<decltype(a0)>(a0));
}
};
inline constexpr protocol_view<const ::xyz::ReferenceInterface>::protocol_view(
protocol_view<::xyz::ReferenceInterface> other) noexcept
: ptr_(other.ptr_), vptr_(&other.vptr_->const_view) {}
} // namespace xyz