-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
tuple
1010 lines (841 loc) · 49.5 KB
/
tuple
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
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// tuple standard header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#pragma once
#ifndef _TUPLE_
#define _TUPLE_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <new>
#include <type_traits>
#include <xutility>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
#if _HAS_CONDITIONAL_EXPLICIT
// VARIABLE TEMPLATE _Tuple_conditional_explicit_v
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_conditional_explicit_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_conditional_explicit_v0<true, tuple<_Dests...>, _Srcs...> =
!conjunction_v<is_convertible<_Srcs, _Dests>...>;
template <class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_conditional_explicit_v =
_Tuple_conditional_explicit_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
// STRUCT TEMPLATE _Tuple_implicit_val
// Constrain tuple's implicit constructors
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_implicit_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_implicit_v0<true, tuple<_Dests...>, _Srcs...> =
conjunction_v<is_constructible<_Dests, _Srcs>..., is_convertible<_Srcs, _Dests>...>;
template <class _Dest, class... _Srcs>
struct _Tuple_implicit_val
: bool_constant<_Tuple_implicit_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>> {};
// STRUCT TEMPLATE _Tuple_explicit_val
// Constrain tuple's explicit constructors
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_explicit_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_explicit_v0<true, tuple<_Dests...>, _Srcs...> =
conjunction_v<is_constructible<_Dests, _Srcs>..., negation<conjunction<is_convertible<_Srcs, _Dests>...>>>;
template <class _Dest, class... _Srcs>
struct _Tuple_explicit_val
: bool_constant<_Tuple_explicit_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>> {};
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
// VARIABLE TEMPLATE _Tuple_constructible_v
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_constructible_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_constructible_v0<true, tuple<_Dests...>, _Srcs...> =
conjunction_v<is_constructible<_Dests, _Srcs>...>;
template <class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_constructible_v =
_Tuple_constructible_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
template <class _Dest, class... _Srcs>
struct _Tuple_constructible_val : bool_constant<_Tuple_constructible_v<_Dest, _Srcs...>> {};
// VARIABLE TEMPLATE _Tuple_nothrow_constructible_v
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_nothrow_constructible_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_nothrow_constructible_v0<true, tuple<_Dests...>, _Srcs...> =
conjunction_v<is_nothrow_constructible<_Dests, _Srcs>...>;
template <class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_nothrow_constructible_v =
_Tuple_nothrow_constructible_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
// VARIABLE TEMPLATE _Tuple_assignable_v
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_assignable_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_assignable_v0<true, tuple<_Dests...>, _Srcs...> =
conjunction_v<is_assignable<_Dests&, _Srcs>...>; // note _Dests& instead of _Dests
template <class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_assignable_v =
_Tuple_assignable_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
template <class _Dest, class... _Srcs>
struct _Tuple_assignable_val : bool_constant<_Tuple_assignable_v<_Dest, _Srcs...>> {};
// VARIABLE TEMPLATE _Tuple_nothrow_assignable_v
template <bool _Same, class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_nothrow_assignable_v0 = false;
template <class... _Dests, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_nothrow_assignable_v0<true, tuple<_Dests...>, _Srcs...> =
conjunction_v<is_nothrow_assignable<_Dests&, _Srcs>...>; // note _Dests& instead of _Dests
template <class _Dest, class... _Srcs>
_INLINE_VAR constexpr bool _Tuple_nothrow_assignable_v =
_Tuple_nothrow_assignable_v0<tuple_size_v<_Dest> == sizeof...(_Srcs), _Dest, _Srcs...>;
// STRUCT TEMPLATE _Tuple_convert_copy_val
// Constrain tuple's converting copy constructor (LWG-2549)
template <class _Myself, class... _Other>
struct _Tuple_convert_copy_val : true_type {};
template <class _This, class _Uty>
struct _Tuple_convert_copy_val<tuple<_This>, _Uty>
: bool_constant<!disjunction_v<is_same<_This, _Uty>, is_constructible<_This, const tuple<_Uty>&>,
is_convertible<const tuple<_Uty>&, _This>>> {};
// STRUCT TEMPLATE _Tuple_convert_move_val
// Constrain tuple's converting move constructor (LWG-2549)
template <class _Myself, class... _Other>
struct _Tuple_convert_move_val : true_type {};
template <class _This, class _Uty>
struct _Tuple_convert_move_val<tuple<_This>, _Uty>
: bool_constant<!disjunction_v<is_same<_This, _Uty>, is_constructible<_This, tuple<_Uty>>,
is_convertible<tuple<_Uty>, _This>>> {};
// STRUCT TEMPLATE _Tuple_perfect_val
// Constrain tuple's perfect forwarding constructor (LWG-3121)
template <class _Myself, class _This2, class... _Rest2>
struct _Tuple_perfect_val : true_type {};
template <class _Myself, class _This2>
struct _Tuple_perfect_val<_Myself, _This2>
: bool_constant<!is_same_v<_Myself, remove_const_t<remove_reference_t<_This2>>>> {};
// STRUCT _Ignore
struct _Ignore { // struct that ignores assignments
template <class _Ty>
constexpr const _Ignore& operator=(const _Ty&) const noexcept /* strengthened */ {
// do nothing
return *this;
}
};
_INLINE_VAR constexpr _Ignore ignore{};
// STRUCT TEMPLATE _Tuple_val
template <class _Ty>
struct _Tuple_val { // stores each value in a tuple
constexpr _Tuple_val() : _Val() {}
template <class _Other>
constexpr _Tuple_val(_Other&& _Arg) : _Val(_STD forward<_Other>(_Arg)) {}
template <class _Alloc, class... _Other, enable_if_t<!uses_allocator_v<_Ty, _Alloc>, int> = 0>
constexpr _Tuple_val(const _Alloc&, allocator_arg_t, _Other&&... _Arg) : _Val(_STD forward<_Other>(_Arg)...) {}
template <class _Alloc, class... _Other,
enable_if_t<conjunction_v<uses_allocator<_Ty, _Alloc>,
is_constructible<_Ty, allocator_arg_t, const _Alloc&, _Other...>>,
int> = 0>
constexpr _Tuple_val(const _Alloc& _Al, allocator_arg_t, _Other&&... _Arg)
: _Val(allocator_arg, _Al, _STD forward<_Other>(_Arg)...) {}
template <class _Alloc, class... _Other,
enable_if_t<conjunction_v<uses_allocator<_Ty, _Alloc>,
negation<is_constructible<_Ty, allocator_arg_t, const _Alloc&, _Other...>>>,
int> = 0>
constexpr _Tuple_val(const _Alloc& _Al, allocator_arg_t, _Other&&... _Arg)
: _Val(_STD forward<_Other>(_Arg)..., _Al) {}
_Ty _Val;
};
// CLASS TEMPLATE tuple
struct _Exact_args_t {
explicit _Exact_args_t() = default;
}; // tag type to disambiguate construction (from one arg per element)
struct _Unpack_tuple_t {
explicit _Unpack_tuple_t() = default;
}; // tag type to disambiguate construction (from unpacking a tuple/pair)
struct _Alloc_exact_args_t {
explicit _Alloc_exact_args_t() = default;
}; // tag type to disambiguate construction (from an allocator and one arg per element)
struct _Alloc_unpack_tuple_t {
explicit _Alloc_unpack_tuple_t() = default;
}; // tag type to disambiguate construction (from an allocator and unpacking a tuple/pair)
template <class... _Types>
class tuple;
template <>
class tuple<> { // empty tuple
public:
constexpr tuple() noexcept /* strengthened */ {}
constexpr tuple(const tuple&) noexcept /* strengthened */ {} // TRANSITION, ABI: should be defaulted
template <class _Alloc>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc&) noexcept /* strengthened */ {}
template <class _Alloc>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept /* strengthened */ {}
template <class _Tag, enable_if_t<is_same_v<_Tag, _Exact_args_t>, int> = 0>
constexpr tuple(_Tag) noexcept /* strengthened */ {}
template <class _Tag, class _Alloc, enable_if_t<is_same_v<_Tag, _Alloc_exact_args_t>, int> = 0>
constexpr tuple(_Tag, const _Alloc&) noexcept /* strengthened */ {}
constexpr tuple& operator=(const tuple&) = default;
_CONSTEXPR20 void swap(tuple&) noexcept {}
constexpr bool _Equals(const tuple&) const noexcept {
return true;
}
constexpr bool _Less(const tuple&) const noexcept {
return false;
}
};
template <class _This, class... _Rest>
class tuple<_This, _Rest...> : private tuple<_Rest...> { // recursive tuple definition
public:
using _This_type = _This;
using _Mybase = tuple<_Rest...>;
template <class _Tag, class _This2, class... _Rest2, enable_if_t<is_same_v<_Tag, _Exact_args_t>, int> = 0>
constexpr tuple(_Tag, _This2&& _This_arg, _Rest2&&... _Rest_arg)
: _Mybase(_Exact_args_t{}, _STD forward<_Rest2>(_Rest_arg)...), _Myfirst(_STD forward<_This2>(_This_arg)) {}
template <class _Tag, class _Tpl, size_t... _Indices, enable_if_t<is_same_v<_Tag, _Unpack_tuple_t>, int> = 0>
constexpr tuple(_Tag, _Tpl&& _Right, index_sequence<_Indices...>);
template <class _Tag, class _Tpl, enable_if_t<is_same_v<_Tag, _Unpack_tuple_t>, int> = 0>
constexpr tuple(_Tag, _Tpl&& _Right)
: tuple(_Unpack_tuple_t{}, _STD forward<_Tpl>(_Right),
make_index_sequence<tuple_size_v<remove_reference_t<_Tpl>>>{}) {}
template <class _Tag, class _Alloc, class _This2, class... _Rest2,
enable_if_t<is_same_v<_Tag, _Alloc_exact_args_t>, int> = 0>
constexpr tuple(_Tag, const _Alloc& _Al, _This2&& _This_arg, _Rest2&&... _Rest_arg)
: _Mybase(_Alloc_exact_args_t{}, _Al, _STD forward<_Rest2>(_Rest_arg)...),
_Myfirst(_Al, allocator_arg, _STD forward<_This2>(_This_arg)) {}
template <class _Tag, class _Alloc, class _Tpl, size_t... _Indices,
enable_if_t<is_same_v<_Tag, _Alloc_unpack_tuple_t>, int> = 0>
constexpr tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right, index_sequence<_Indices...>);
template <class _Tag, class _Alloc, class _Tpl, enable_if_t<is_same_v<_Tag, _Alloc_unpack_tuple_t>, int> = 0>
constexpr tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD forward<_Tpl>(_Right),
make_index_sequence<tuple_size_v<remove_reference_t<_Tpl>>>{}) {}
#if _HAS_CONDITIONAL_EXPLICIT
template <class _This2 = _This,
enable_if_t<conjunction_v<is_default_constructible<_This2>, is_default_constructible<_Rest>...>, int> = 0>
constexpr explicit(
!conjunction_v<_Is_implicitly_default_constructible<_This2>, _Is_implicitly_default_constructible<_Rest>...>)
tuple() noexcept(conjunction_v<is_nothrow_default_constructible<_This2>,
is_nothrow_default_constructible<_Rest>...>) // strengthened
: _Mybase(), _Myfirst() {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _This2 = _This,
enable_if_t<conjunction_v<is_default_constructible<_This2>, is_default_constructible<_Rest>...,
_Is_implicitly_default_constructible<_This2>, _Is_implicitly_default_constructible<_Rest>...>,
int> = 0>
constexpr tuple() noexcept(conjunction_v<is_nothrow_default_constructible<_This2>,
is_nothrow_default_constructible<_Rest>...>) // strengthened
: _Mybase(), _Myfirst() {}
template <class _This2 = _This,
enable_if_t<conjunction_v<is_default_constructible<_This2>, is_default_constructible<_Rest>...,
negation<conjunction<_Is_implicitly_default_constructible<_This2>,
_Is_implicitly_default_constructible<_Rest>...>>>,
int> = 0>
constexpr explicit tuple() noexcept(conjunction_v<is_nothrow_default_constructible<_This2>,
is_nothrow_default_constructible<_Rest>...>) // strengthened
: _Mybase(), _Myfirst() {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _This2 = _This, enable_if_t<_Tuple_constructible_v<tuple, const _This2&, const _Rest&...>, int> = 0>
constexpr explicit(_Tuple_conditional_explicit_v<tuple, const _This2&, const _Rest&...>) tuple(
const _This& _This_arg, const _Rest&... _Rest_arg) noexcept(conjunction_v<is_nothrow_copy_constructible<_This2>,
is_nothrow_copy_constructible<_Rest>...>) // strengthened
: tuple(_Exact_args_t{}, _This_arg, _Rest_arg...) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _This2 = _This,
enable_if_t<_Tuple_implicit_val<tuple, const _This2&, const _Rest&...>::value, int> = 0>
constexpr tuple(const _This& _This_arg, const _Rest&... _Rest_arg) noexcept(
conjunction_v<is_nothrow_copy_constructible<_This2>,
is_nothrow_copy_constructible<_Rest>...>) // strengthened
: tuple(_Exact_args_t{}, _This_arg, _Rest_arg...) {}
template <class _This2 = _This,
enable_if_t<_Tuple_explicit_val<tuple, const _This2&, const _Rest&...>::value, int> = 0>
constexpr explicit tuple(const _This& _This_arg, const _Rest&... _Rest_arg) noexcept(
conjunction_v<is_nothrow_copy_constructible<_This2>,
is_nothrow_copy_constructible<_Rest>...>) // strengthened
: tuple(_Exact_args_t{}, _This_arg, _Rest_arg...) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _This2, class... _Rest2,
enable_if_t<conjunction_v<_Tuple_perfect_val<tuple, _This2, _Rest2...>,
_Tuple_constructible_val<tuple, _This2, _Rest2...>>,
int> = 0>
constexpr explicit(_Tuple_conditional_explicit_v<tuple, _This2, _Rest2...>) tuple(_This2&& _This_arg,
_Rest2&&... _Rest_arg) noexcept(_Tuple_nothrow_constructible_v<tuple, _This2, _Rest2...>) // strengthened
: tuple(_Exact_args_t{}, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _This2, class... _Rest2,
enable_if_t<
conjunction_v<_Tuple_perfect_val<tuple, _This2, _Rest2...>, _Tuple_implicit_val<tuple, _This2, _Rest2...>>,
int> = 0>
constexpr tuple(_This2&& _This_arg, _Rest2&&... _Rest_arg) noexcept(
_Tuple_nothrow_constructible_v<tuple, _This2, _Rest2...>) // strengthened
: tuple(_Exact_args_t{}, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {}
template <class _This2, class... _Rest2,
enable_if_t<
conjunction_v<_Tuple_perfect_val<tuple, _This2, _Rest2...>, _Tuple_explicit_val<tuple, _This2, _Rest2...>>,
int> = 0>
constexpr explicit tuple(_This2&& _This_arg, _Rest2&&... _Rest_arg) noexcept(
_Tuple_nothrow_constructible_v<tuple, _This2, _Rest2...>) // strengthened
: tuple(_Exact_args_t{}, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
tuple(const tuple&) = default;
tuple(tuple&&) = default;
#if _HAS_CONDITIONAL_EXPLICIT
template <class... _Other, enable_if_t<conjunction_v<_Tuple_constructible_val<tuple, const _Other&...>,
_Tuple_convert_copy_val<tuple, _Other...>>,
int> = 0>
constexpr explicit(_Tuple_conditional_explicit_v<tuple, const _Other&...>)
tuple(const tuple<_Other...>& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, const _Other&...>) // strengthened
: tuple(_Unpack_tuple_t{}, _Right) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class... _Other, enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, const _Other&...>,
_Tuple_convert_copy_val<tuple, _Other...>>,
int> = 0>
constexpr tuple(const tuple<_Other...>& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, const _Other&...>) // strengthened
: tuple(_Unpack_tuple_t{}, _Right) {}
template <class... _Other, enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, const _Other&...>,
_Tuple_convert_copy_val<tuple, _Other...>>,
int> = 0>
constexpr explicit tuple(const tuple<_Other...>& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, const _Other&...>) // strengthened
: tuple(_Unpack_tuple_t{}, _Right) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class... _Other, enable_if_t<conjunction_v<_Tuple_constructible_val<tuple, _Other...>,
_Tuple_convert_move_val<tuple, _Other...>>,
int> = 0>
constexpr explicit(_Tuple_conditional_explicit_v<tuple, _Other...>)
tuple(tuple<_Other...>&& _Right) noexcept(_Tuple_nothrow_constructible_v<tuple, _Other...>) // strengthened
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class... _Other,
enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
int> = 0>
constexpr tuple(tuple<_Other...>&& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, _Other...>) // strengthened
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
template <class... _Other,
enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
int> = 0>
constexpr explicit tuple(tuple<_Other...>&& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, _Other...>) // strengthened
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _First, class _Second,
enable_if_t<_Tuple_constructible_v<tuple, const _First&, const _Second&>, int> = 0>
constexpr explicit(_Tuple_conditional_explicit_v<tuple, const _First&, const _Second&>)
tuple(const pair<_First, _Second>& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, const _First&, const _Second&>) // strengthened
: tuple(_Unpack_tuple_t{}, _Right) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _First, class _Second,
enable_if_t<_Tuple_implicit_val<tuple, const _First&, const _Second&>::value, int> = 0>
constexpr tuple(const pair<_First, _Second>& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, const _First&, const _Second&>) // strengthened
: tuple(_Unpack_tuple_t{}, _Right) {}
template <class _First, class _Second,
enable_if_t<_Tuple_explicit_val<tuple, const _First&, const _Second&>::value, int> = 0>
constexpr explicit tuple(const pair<_First, _Second>& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, const _First&, const _Second&>) // strengthened
: tuple(_Unpack_tuple_t{}, _Right) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _First, class _Second, enable_if_t<_Tuple_constructible_v<tuple, _First, _Second>, int> = 0>
constexpr explicit(_Tuple_conditional_explicit_v<tuple, _First, _Second>) tuple(
pair<_First, _Second>&& _Right) noexcept(_Tuple_nothrow_constructible_v<tuple, _First, _Second>) // strengthened
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _First, class _Second, enable_if_t<_Tuple_implicit_val<tuple, _First, _Second>::value, int> = 0>
constexpr tuple(pair<_First, _Second>&& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, _First, _Second>) // strengthened
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
template <class _First, class _Second, enable_if_t<_Tuple_explicit_val<tuple, _First, _Second>::value, int> = 0>
constexpr explicit tuple(pair<_First, _Second>&& _Right) noexcept(
_Tuple_nothrow_constructible_v<tuple, _First, _Second>) // strengthened
: tuple(_Unpack_tuple_t{}, _STD move(_Right)) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class _This2 = _This,
enable_if_t<conjunction_v<is_default_constructible<_This2>, is_default_constructible<_Rest>...>, int> = 0>
_CONSTEXPR20 explicit(
!conjunction_v<_Is_implicitly_default_constructible<_This2>, _Is_implicitly_default_constructible<_Rest>...>)
tuple(allocator_arg_t, const _Alloc& _Al)
: _Mybase(allocator_arg, _Al), _Myfirst(_Al, allocator_arg) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class _This2 = _This,
enable_if_t<conjunction_v<is_default_constructible<_This2>, is_default_constructible<_Rest>...,
_Is_implicitly_default_constructible<_This2>, _Is_implicitly_default_constructible<_Rest>...>,
int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al)
: _Mybase(allocator_arg, _Al), _Myfirst(_Al, allocator_arg) {}
template <class _Alloc, class _This2 = _This,
enable_if_t<conjunction_v<is_default_constructible<_This2>, is_default_constructible<_Rest>...,
negation<conjunction<_Is_implicitly_default_constructible<_This2>,
_Is_implicitly_default_constructible<_Rest>...>>>,
int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al)
: _Mybase(allocator_arg, _Al), _Myfirst(_Al, allocator_arg) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class _This2 = _This,
enable_if_t<_Tuple_constructible_v<tuple, const _This2&, const _Rest&...>, int> = 0>
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, const _This2&, const _Rest&...>)
tuple(allocator_arg_t, const _Alloc& _Al, const _This& _This_arg, const _Rest&... _Rest_arg)
: tuple(_Alloc_exact_args_t{}, _Al, _This_arg, _Rest_arg...) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class _This2 = _This,
enable_if_t<_Tuple_implicit_val<tuple, const _This2&, const _Rest&...>::value, int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, const _This& _This_arg, const _Rest&... _Rest_arg)
: tuple(_Alloc_exact_args_t{}, _Al, _This_arg, _Rest_arg...) {}
template <class _Alloc, class _This2 = _This,
enable_if_t<_Tuple_explicit_val<tuple, const _This2&, const _Rest&...>::value, int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, const _This& _This_arg, const _Rest&... _Rest_arg)
: tuple(_Alloc_exact_args_t{}, _Al, _This_arg, _Rest_arg...) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class _This2, class... _Rest2,
enable_if_t<conjunction_v<_Tuple_perfect_val<tuple, _This2, _Rest2...>,
_Tuple_constructible_val<tuple, _This2, _Rest2...>>,
int> = 0>
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, _This2, _Rest2...>)
tuple(allocator_arg_t, const _Alloc& _Al, _This2&& _This_arg, _Rest2&&... _Rest_arg)
: tuple(_Alloc_exact_args_t{}, _Al, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class _This2, class... _Rest2,
enable_if_t<
conjunction_v<_Tuple_perfect_val<tuple, _This2, _Rest2...>, _Tuple_implicit_val<tuple, _This2, _Rest2...>>,
int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, _This2&& _This_arg, _Rest2&&... _Rest_arg)
: tuple(_Alloc_exact_args_t{}, _Al, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {}
template <class _Alloc, class _This2, class... _Rest2,
enable_if_t<
conjunction_v<_Tuple_perfect_val<tuple, _This2, _Rest2...>, _Tuple_explicit_val<tuple, _This2, _Rest2...>>,
int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, _This2&& _This_arg, _Rest2&&... _Rest_arg)
: tuple(_Alloc_exact_args_t{}, _Al, _STD forward<_This2>(_This_arg), _STD forward<_Rest2>(_Rest_arg)...) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
template <class _Alloc, class _This2 = _This,
enable_if_t<_Tuple_constructible_v<tuple, const _This2&, const _Rest&...>, int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, const tuple& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
template <class _Alloc, class _This2 = _This, enable_if_t<_Tuple_constructible_v<tuple, _This2, _Rest...>, int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, tuple&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class... _Other,
enable_if_t<
conjunction_v<_Tuple_constructible_val<tuple, const _Other&...>, _Tuple_convert_copy_val<tuple, _Other...>>,
int> = 0>
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, const _Other&...>)
tuple(allocator_arg_t, const _Alloc& _Al, const tuple<_Other...>& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class... _Other,
enable_if_t<
conjunction_v<_Tuple_implicit_val<tuple, const _Other&...>, _Tuple_convert_copy_val<tuple, _Other...>>,
int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, const tuple<_Other...>& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
template <class _Alloc, class... _Other,
enable_if_t<
conjunction_v<_Tuple_explicit_val<tuple, const _Other&...>, _Tuple_convert_copy_val<tuple, _Other...>>,
int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, const tuple<_Other...>& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class... _Other,
enable_if_t<
conjunction_v<_Tuple_constructible_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>, int> =
0>
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, _Other...>)
tuple(allocator_arg_t, const _Alloc& _Al, tuple<_Other...>&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class... _Other,
enable_if_t<conjunction_v<_Tuple_implicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, tuple<_Other...>&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
template <class _Alloc, class... _Other,
enable_if_t<conjunction_v<_Tuple_explicit_val<tuple, _Other...>, _Tuple_convert_move_val<tuple, _Other...>>,
int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, tuple<_Other...>&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class _First, class _Second,
enable_if_t<_Tuple_constructible_v<tuple, const _First&, const _Second&>, int> = 0>
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, const _First&, const _Second&>)
tuple(allocator_arg_t, const _Alloc& _Al, const pair<_First, _Second>& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class _First, class _Second,
enable_if_t<_Tuple_implicit_val<tuple, const _First&, const _Second&>::value, int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, const pair<_First, _Second>& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
template <class _Alloc, class _First, class _Second,
enable_if_t<_Tuple_explicit_val<tuple, const _First&, const _Second&>::value, int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, const pair<_First, _Second>& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _Right) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
#if _HAS_CONDITIONAL_EXPLICIT
template <class _Alloc, class _First, class _Second,
enable_if_t<_Tuple_constructible_v<tuple, _First, _Second>, int> = 0>
_CONSTEXPR20 explicit(_Tuple_conditional_explicit_v<tuple, _First, _Second>)
tuple(allocator_arg_t, const _Alloc& _Al, pair<_First, _Second>&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Alloc, class _First, class _Second,
enable_if_t<_Tuple_implicit_val<tuple, _First, _Second>::value, int> = 0>
_CONSTEXPR20 tuple(allocator_arg_t, const _Alloc& _Al, pair<_First, _Second>&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
template <class _Alloc, class _First, class _Second,
enable_if_t<_Tuple_explicit_val<tuple, _First, _Second>::value, int> = 0>
_CONSTEXPR20 explicit tuple(allocator_arg_t, const _Alloc& _Al, pair<_First, _Second>&& _Right)
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^
tuple& operator=(const volatile tuple&) = delete;
template <class _Myself = tuple, class _This2 = _This,
enable_if_t<conjunction_v<_Is_copy_assignable_no_precondition_check<_This2>,
_Is_copy_assignable_no_precondition_check<_Rest>...>,
int> = 0>
_CONSTEXPR20 tuple& operator=(_Identity_t<const _Myself&> _Right) noexcept(
conjunction_v<is_nothrow_copy_assignable<_This2>, is_nothrow_copy_assignable<_Rest>...>) /* strengthened */ {
_Myfirst._Val = _Right._Myfirst._Val;
_Get_rest() = _Right._Get_rest();
return *this;
}
template <class _Myself = tuple, class _This2 = _This,
enable_if_t<conjunction_v<_Is_move_assignable_no_precondition_check<_This2>,
_Is_move_assignable_no_precondition_check<_Rest>...>,
int> = 0>
_CONSTEXPR20 tuple& operator=(_Identity_t<_Myself&&> _Right) noexcept(
conjunction_v<is_nothrow_move_assignable<_This2>, is_nothrow_move_assignable<_Rest>...>) {
_Myfirst._Val = _STD forward<_This>(_Right._Myfirst._Val);
_Get_rest() = _STD forward<_Mybase>(_Right._Get_rest());
return *this;
}
template <class... _Other, enable_if_t<conjunction_v<negation<is_same<tuple, tuple<_Other...>>>,
_Tuple_assignable_val<tuple, const _Other&...>>,
int> = 0>
_CONSTEXPR20 tuple& operator=(const tuple<_Other...>& _Right) noexcept(
_Tuple_nothrow_assignable_v<tuple, const _Other&...>) /* strengthened */ {
_Myfirst._Val = _Right._Myfirst._Val;
_Get_rest() = _Right._Get_rest();
return *this;
}
template <class... _Other,
enable_if_t<conjunction_v<negation<is_same<tuple, tuple<_Other...>>>, _Tuple_assignable_val<tuple, _Other...>>,
int> = 0>
_CONSTEXPR20 tuple& operator=(tuple<_Other...>&& _Right) noexcept(
_Tuple_nothrow_assignable_v<tuple, _Other...>) /* strengthened */ {
_Myfirst._Val = _STD forward<typename tuple<_Other...>::_This_type>(_Right._Myfirst._Val);
_Get_rest() = _STD forward<typename tuple<_Other...>::_Mybase>(_Right._Get_rest());
return *this;
}
template <class _First, class _Second,
enable_if_t<_Tuple_assignable_v<tuple, const _First&, const _Second&>, int> = 0>
_CONSTEXPR20 tuple& operator=(const pair<_First, _Second>& _Right) noexcept(
_Tuple_nothrow_assignable_v<tuple, const _First&, const _Second&>) /* strengthened */ {
_Myfirst._Val = _Right.first;
_Get_rest()._Myfirst._Val = _Right.second;
return *this;
}
template <class _First, class _Second, enable_if_t<_Tuple_assignable_v<tuple, _First, _Second>, int> = 0>
_CONSTEXPR20 tuple& operator=(pair<_First, _Second>&& _Right) noexcept(
_Tuple_nothrow_assignable_v<tuple, _First, _Second>) /* strengthened */ {
_Myfirst._Val = _STD forward<_First>(_Right.first);
_Get_rest()._Myfirst._Val = _STD forward<_Second>(_Right.second);
return *this;
}
_CONSTEXPR20 void swap(tuple& _Right) noexcept(
conjunction_v<_Is_nothrow_swappable<_This>, _Is_nothrow_swappable<_Rest>...>) {
_Swap_adl(_Myfirst._Val, _Right._Myfirst._Val);
_Mybase::swap(_Right._Get_rest());
}
constexpr _Mybase& _Get_rest() noexcept { // get reference to rest of elements
return *this;
}
constexpr const _Mybase& _Get_rest() const noexcept { // get const reference to rest of elements
return *this;
}
template <class... _Other>
constexpr bool _Equals(const tuple<_Other...>& _Right) const {
return _Myfirst._Val == _Right._Myfirst._Val && _Mybase::_Equals(_Right._Get_rest());
}
template <class... _Other>
constexpr bool _Less(const tuple<_Other...>& _Right) const {
return _Myfirst._Val < _Right._Myfirst._Val
|| (!(_Right._Myfirst._Val < _Myfirst._Val) && _Mybase::_Less(_Right._Get_rest()));
}
template <size_t _Index, class... _Types>
friend constexpr tuple_element_t<_Index, tuple<_Types...>>& get(tuple<_Types...>& _Tuple) noexcept;
template <size_t _Index, class... _Types>
friend constexpr const tuple_element_t<_Index, tuple<_Types...>>& get(const tuple<_Types...>& _Tuple) noexcept;
template <size_t _Index, class... _Types>
friend constexpr tuple_element_t<_Index, tuple<_Types...>>&& get(tuple<_Types...>&& _Tuple) noexcept;
template <size_t _Index, class... _Types>
friend constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const tuple<_Types...>&& _Tuple) noexcept;
template <class _Ty, class... _Types>
friend constexpr _Ty& get(tuple<_Types...>& _Tuple) noexcept;
template <class _Ty, class... _Types>
friend constexpr const _Ty& get(const tuple<_Types...>& _Tuple) noexcept;
template <class _Ty, class... _Types>
friend constexpr _Ty&& get(tuple<_Types...>&& _Tuple) noexcept;
template <class _Ty, class... _Types>
friend constexpr const _Ty&& get(const tuple<_Types...>&& _Tuple) noexcept;
_Tuple_val<_This> _Myfirst; // the stored element
};
#if _HAS_CXX17
template <class... _Types>
tuple(_Types...) -> tuple<_Types...>;
template <class _Ty1, class _Ty2>
tuple(pair<_Ty1, _Ty2>) -> tuple<_Ty1, _Ty2>;
template <class _Alloc, class... _Types>
tuple(allocator_arg_t, _Alloc, _Types...) -> tuple<_Types...>;
template <class _Alloc, class _Ty1, class _Ty2>
tuple(allocator_arg_t, _Alloc, pair<_Ty1, _Ty2>) -> tuple<_Ty1, _Ty2>;
template <class _Alloc, class... _Types>
tuple(allocator_arg_t, _Alloc, tuple<_Types...>) -> tuple<_Types...>;
#endif // _HAS_CXX17
// OPERATORS FOR tuple
template <class... _Types1, class... _Types2>
_NODISCARD constexpr bool operator==(const tuple<_Types1...>& _Left, const tuple<_Types2...>& _Right) {
static_assert(sizeof...(_Types1) == sizeof...(_Types2), "cannot compare tuples of different sizes");
return _Left._Equals(_Right);
}
template <class... _Types1, class... _Types2>
_NODISCARD constexpr bool operator!=(const tuple<_Types1...>& _Left, const tuple<_Types2...>& _Right) {
return !(_Left == _Right);
}
template <class... _Types1, class... _Types2>
_NODISCARD constexpr bool operator<(const tuple<_Types1...>& _Left, const tuple<_Types2...>& _Right) {
static_assert(sizeof...(_Types1) == sizeof...(_Types2), "cannot compare tuples of different sizes");
return _Left._Less(_Right);
}
template <class... _Types1, class... _Types2>
_NODISCARD constexpr bool operator>=(const tuple<_Types1...>& _Left, const tuple<_Types2...>& _Right) {
return !(_Left < _Right);
}
template <class... _Types1, class... _Types2>
_NODISCARD constexpr bool operator>(const tuple<_Types1...>& _Left, const tuple<_Types2...>& _Right) {
return _Right < _Left;
}
template <class... _Types1, class... _Types2>
_NODISCARD constexpr bool operator<=(const tuple<_Types1...>& _Left, const tuple<_Types2...>& _Right) {
return !(_Right < _Left);
}
template <class... _Types, enable_if_t<conjunction_v<_Is_swappable<_Types>...>, int> = 0>
_CONSTEXPR20 void swap(tuple<_Types...>& _Left, tuple<_Types...>& _Right) noexcept(noexcept(_Left.swap(_Right))) {
return _Left.swap(_Right);
}
// CLASS _Tuple_element (find element by type)
template <class _Ty, class _Tuple>
struct _Tuple_element {}; // backstop _Tuple_element definition
template <class _This, class... _Rest>
struct _Tuple_element<_This, tuple<_This, _Rest...>> { // select first element
static_assert(!_Is_any_of_v<_This, _Rest...>, "duplicate type T in get<T>(tuple)");
using _Ttype = tuple<_This, _Rest...>;
};
template <class _Ty, class _This, class... _Rest>
struct _Tuple_element<_Ty, tuple<_This, _Rest...>> { // recursive _Tuple_element definition
using _Ttype = typename _Tuple_element<_Ty, tuple<_Rest...>>::_Ttype;
};
// FUNCTION TEMPLATE get (by index)
template <size_t _Index, class... _Types>
_NODISCARD constexpr tuple_element_t<_Index, tuple<_Types...>>& get(tuple<_Types...>& _Tuple) noexcept {
using _Ttype = typename tuple_element<_Index, tuple<_Types...>>::_Ttype;
return static_cast<_Ttype&>(_Tuple)._Myfirst._Val;
}
template <size_t _Index, class... _Types>
_NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>& get(const tuple<_Types...>& _Tuple) noexcept {
using _Ttype = typename tuple_element<_Index, tuple<_Types...>>::_Ttype;
return static_cast<const _Ttype&>(_Tuple)._Myfirst._Val;
}
template <size_t _Index, class... _Types>
_NODISCARD constexpr tuple_element_t<_Index, tuple<_Types...>>&& get(tuple<_Types...>&& _Tuple) noexcept {
using _Ty = tuple_element_t<_Index, tuple<_Types...>>;
using _Ttype = typename tuple_element<_Index, tuple<_Types...>>::_Ttype;
return static_cast<_Ty&&>(static_cast<_Ttype&>(_Tuple)._Myfirst._Val);
}
template <size_t _Index, class... _Types>
_NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const tuple<_Types...>&& _Tuple) noexcept {
using _Ty = tuple_element_t<_Index, tuple<_Types...>>;
using _Ttype = typename tuple_element<_Index, tuple<_Types...>>::_Ttype;
return static_cast<const _Ty&&>(static_cast<const _Ttype&>(_Tuple)._Myfirst._Val);
}
// FUNCTION TEMPLATE get (by type)
template <class _Ty, class... _Types>
_NODISCARD constexpr _Ty& get(tuple<_Types...>& _Tuple) noexcept {
using _Ttype = typename _Tuple_element<_Ty, tuple<_Types...>>::_Ttype;
return static_cast<_Ttype&>(_Tuple)._Myfirst._Val;
}
template <class _Ty, class... _Types>
_NODISCARD constexpr const _Ty& get(const tuple<_Types...>& _Tuple) noexcept {
using _Ttype = typename _Tuple_element<_Ty, tuple<_Types...>>::_Ttype;
return static_cast<const _Ttype&>(_Tuple)._Myfirst._Val;
}
template <class _Ty, class... _Types>
_NODISCARD constexpr _Ty&& get(tuple<_Types...>&& _Tuple) noexcept {
using _Ttype = typename _Tuple_element<_Ty, tuple<_Types...>>::_Ttype;
return static_cast<_Ty&&>(static_cast<_Ttype&>(_Tuple)._Myfirst._Val);
}
template <class _Ty, class... _Types>
_NODISCARD constexpr const _Ty&& get(const tuple<_Types...>&& _Tuple) noexcept {
using _Ttype = typename _Tuple_element<_Ty, tuple<_Types...>>::_Ttype;
return static_cast<const _Ty&&>(static_cast<const _Ttype&>(_Tuple)._Myfirst._Val);
}
// CONSTRUCTOR TEMPLATES FOR tuple
template <class _This, class... _Rest>
template <class _Tag, class _Tpl, size_t... _Indices, enable_if_t<is_same_v<_Tag, _Unpack_tuple_t>, int>>
constexpr tuple<_This, _Rest...>::tuple(_Tag, _Tpl&& _Right, index_sequence<_Indices...>)
: tuple(_Exact_args_t{}, _STD get<_Indices>(_STD forward<_Tpl>(_Right))...) {}
template <class _This, class... _Rest>
template <class _Tag, class _Alloc, class _Tpl, size_t... _Indices,
enable_if_t<is_same_v<_Tag, _Alloc_unpack_tuple_t>, int>>
constexpr tuple<_This, _Rest...>::tuple(_Tag, const _Alloc& _Al, _Tpl&& _Right, index_sequence<_Indices...>)
: tuple(_Alloc_exact_args_t{}, _Al, _STD get<_Indices>(_STD forward<_Tpl>(_Right))...) {}
// FUNCTION TEMPLATE make_tuple
template <class... _Types>
_NODISCARD constexpr tuple<_Unrefwrap_t<_Types>...> make_tuple(_Types&&... _Args) { // make tuple from elements
using _Ttype = tuple<_Unrefwrap_t<_Types>...>;
return _Ttype(_STD forward<_Types>(_Args)...);
}
// FUNCTION TEMPLATE tie
template <class... _Types>
_NODISCARD constexpr tuple<_Types&...> tie(_Types&... _Args) noexcept { // make tuple from elements
using _Ttype = tuple<_Types&...>;
return _Ttype(_Args...);
}
// FUNCTION TEMPLATE forward_as_tuple
template <class... _Types>
_NODISCARD constexpr tuple<_Types&&...> forward_as_tuple(_Types&&... _Args) noexcept { // forward arguments in a tuple
return tuple<_Types&&...>(_STD forward<_Types>(_Args)...);
}
// STRUCT TEMPLATE _Cat_sequences
template <class _Seq_type1, class _Seq_type2>
struct _Cat_sequences;
template <size_t... _Indexes1, size_t... _Indexes2>
struct _Cat_sequences<index_sequence<_Indexes1...>,
index_sequence<_Indexes2...>> { // concatenates two index_sequence types
using type = index_sequence<_Indexes1..., _Indexes2...>;
};
// FORWARD DECLARATIONS
template <class _Ty, size_t _Size>
class array;
template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept;
template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept;
template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept;
template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept;
// STRUCT TEMPLATE _View_as_tuple
template <class _Ty, class... _For_array>
struct _View_as_tuple { // tuple_cat() supports only tuples, pairs, and arrays
static_assert(_Always_false<_Ty>, "Unsupported tuple_cat arguments.");
};
template <class... _Types>
struct _View_as_tuple<tuple<_Types...>> { // view a tuple as a tuple
using type = tuple<_Types...>;
};
template <class _Ty1, class _Ty2>
struct _View_as_tuple<pair<_Ty1, _Ty2>> { // view a pair as a tuple
using type = tuple<_Ty1, _Ty2>;
};
template <class _Ty, class... _Types>
struct _View_as_tuple<array<_Ty, 0>, _Types...> { // view an array as a tuple; ends recursion at 0
using type = tuple<_Types...>;
};
template <class _Ty, size_t _Size, class... _Types>
struct _View_as_tuple<array<_Ty, _Size>, _Types...>
: _View_as_tuple<array<_Ty, _Size - 1>, _Ty, _Types...> { // view an array as a tuple; counts down to 0
};
// STRUCT TEMPLATE _Repeat_for
template <size_t _Nx, class _Ty>
struct _Repeat_for : integral_constant<size_t, _Nx> {}; // repeats _Nx for each _Ty in a parameter pack
// FUNCTION TEMPLATE tuple_cat
template <class _Ret, class _Kx_arg, class _Ix_arg, size_t _Ix_next, class... _Tuples>
struct _Tuple_cat2 { // determine tuple_cat's return type and _Kx/_Ix indices
static_assert(sizeof...(_Tuples) == 0, "Unsupported tuple_cat arguments.");
using type = _Ret;
using _Kx_arg_seq = _Kx_arg;
using _Ix_arg_seq = _Ix_arg;
};
template <class... _Types1, class _Kx_arg, size_t... _Ix, size_t _Ix_next, class... _Types2, class... _Rest>
struct _Tuple_cat2<tuple<_Types1...>, _Kx_arg, index_sequence<_Ix...>, _Ix_next, tuple<_Types2...>, _Rest...>
: _Tuple_cat2<tuple<_Types1..., _Types2...>, typename _Cat_sequences<_Kx_arg, index_sequence_for<_Types2...>>::type,
index_sequence<_Ix..., _Repeat_for<_Ix_next, _Types2>::value...>, _Ix_next + 1,
_Rest...> { // determine tuple_cat's return type and _Kx/_Ix indices
};
template <class... _Tuples>
struct _Tuple_cat1 : _Tuple_cat2<tuple<>, index_sequence<>, index_sequence<>, 0,
typename _View_as_tuple<decay_t<_Tuples>>::type...> { // prepare to determine tuple_cat's
// return type and _Kx/_Ix indices
};
template <class _Ret, size_t... _Kx, size_t... _Ix, class _Ty>
constexpr _Ret _Tuple_cat(index_sequence<_Kx...>, index_sequence<_Ix...>, _Ty&& _Arg) { // concatenate tuples
return _Ret(_STD get<_Kx>(_STD get<_Ix>(_STD forward<_Ty>(_Arg)))...);
}
template <class... _Tuples>
_NODISCARD constexpr typename _Tuple_cat1<_Tuples...>::type tuple_cat(_Tuples&&... _Tpls) { // concatenate tuples
using _Cat1 = _Tuple_cat1<_Tuples...>;
return _Tuple_cat<typename _Cat1::type>(typename _Cat1::_Kx_arg_seq(), typename _Cat1::_Ix_arg_seq(),
_STD forward_as_tuple(_STD forward<_Tuples>(_Tpls)...));
}
#if _HAS_CXX17
// FUNCTION TEMPLATE apply
template <class _Callable, class _Tuple, size_t... _Indices>
constexpr decltype(auto) _Apply_impl(
_Callable&& _Obj, _Tuple&& _Tpl, index_sequence<_Indices...>) { // invoke _Obj with the elements of _Tpl
return _STD invoke(_STD forward<_Callable>(_Obj), _STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...);
}
template <class _Callable, class _Tuple>
constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) { // invoke _Obj with the elements of _Tpl
return _Apply_impl(_STD forward<_Callable>(_Obj), _STD forward<_Tuple>(_Tpl),
make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>{});
}
// FUNCTION TEMPLATE make_from_tuple
template <class _Ty, class _Tuple, size_t... _Indices>
constexpr _Ty _Make_from_tuple_impl(
_Tuple&& _Tpl, index_sequence<_Indices...>) { // construct _Ty from the elements of _Tpl
return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...);
}
template <class _Ty, class _Tuple>
_NODISCARD constexpr _Ty make_from_tuple(_Tuple&& _Tpl) { // construct _Ty from the elements of _Tpl
return _Make_from_tuple_impl<_Ty>(
_STD forward<_Tuple>(_Tpl), make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>{});
}
#endif // _HAS_CXX17
// TEMPLATE CONSTRUCTOR pair::pair(tuple, tuple, sequence, sequence)
template <class _Ty1, class _Ty2>
template <class _Tuple1, class _Tuple2, size_t... _Indexes1, size_t... _Indexes2>
constexpr pair<_Ty1, _Ty2>::pair(
_Tuple1& _Val1, _Tuple2& _Val2, index_sequence<_Indexes1...>, index_sequence<_Indexes2...>)
: first(_STD get<_Indexes1>(_STD move(_Val1))...), second(_STD get<_Indexes2>(_STD move(_Val2))...) {}
// TEMPLATE CONSTRUCTOR pair::pair(piecewise_construct_t, tuple, tuple)
template <class _Ty1, class _Ty2>
template <class... _Types1, class... _Types2>
_CONSTEXPR20 pair<_Ty1, _Ty2>::pair(piecewise_construct_t, tuple<_Types1...> _Val1, tuple<_Types2...> _Val2)
: pair(_Val1, _Val2, index_sequence_for<_Types1...>{}, index_sequence_for<_Types2...>{}) {}
// STRUCT TEMPLATE uses_allocator
template <class... _Types, class _Alloc>
struct uses_allocator<tuple<_Types...>, _Alloc> : true_type {}; // true_type if container allocator enabled
#if _HAS_TR1_NAMESPACE
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
using _STD get;
using _STD ignore;
using _STD make_tuple;
using _STD ref;
using _STD tie;
using _STD tuple;
} // namespace tr1