-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathutility
997 lines (831 loc) · 41.3 KB
/
utility
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
// utility standard header (core)
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _UTILITY_
#define _UTILITY_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <initializer_list>
#include <type_traits>
#if _HAS_CXX20
#include <compare>
#include <concepts>
#endif // _HAS_CXX20
#if _HAS_CXX23
#include <cstdlib>
#endif // _HAS_CXX23
#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
// TRANSITION, non-_Ugly attribute tokens
#pragma push_macro("msvc")
#pragma push_macro("intrinsic")
#pragma push_macro("known_semantics")
#pragma push_macro("lifetimebound")
#undef msvc
#undef intrinsic
#undef known_semantics
#undef lifetimebound
_STD_BEGIN
_EXPORT_STD template <class _Ty, _Ty... _Vals>
struct integer_sequence { // sequence of integer parameters
static_assert(is_integral_v<_Ty>, "integer_sequence<T, I...> requires T to be an integral type.");
using value_type = _Ty;
_NODISCARD static constexpr size_t size() noexcept {
return sizeof...(_Vals);
}
};
_EXPORT_STD template <class _Ty, _Ty _Size>
using make_integer_sequence = __make_integer_seq<integer_sequence, _Ty, _Size>;
_EXPORT_STD template <size_t... _Vals>
using index_sequence = integer_sequence<size_t, _Vals...>;
_EXPORT_STD template <size_t _Size>
using make_index_sequence = make_integer_sequence<size_t, _Size>;
_EXPORT_STD template <class... _Types>
using index_sequence_for = make_index_sequence<sizeof...(_Types)>;
_EXPORT_STD template <class _Ty, class _Pr>
_NODISCARD constexpr const _Ty&(max) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND,
_Pr _Pred) noexcept(noexcept(_Pred(_Left, _Right))) /* strengthened */ {
// return larger of _Left and _Right
return _Pred(_Left, _Right) ? _Right : _Left;
}
#pragma warning(push)
#pragma warning(disable : 28285) // (syntax error in SAL annotation, occurs when _Ty is not an integral type)
_EXPORT_STD template <class _Ty>
_NODISCARD _Post_equal_to_(_Left < _Right ? _Right : _Left) constexpr const _Ty& //
(max) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND)
noexcept(noexcept(_Left < _Right)) /* strengthened */ {
// return larger of _Left and _Right
return _Left < _Right ? _Right : _Left;
}
#pragma warning(pop)
_EXPORT_STD template <class _Ty, class _Pr>
_NODISCARD constexpr _Ty(max)(initializer_list<_Ty>, _Pr); // implemented in <algorithm>
_EXPORT_STD template <class _Ty>
_NODISCARD constexpr _Ty(max)(initializer_list<_Ty>); // implemented in <algorithm>
_EXPORT_STD template <class _Ty, class _Pr>
_NODISCARD constexpr const _Ty&(min) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND,
_Pr _Pred) noexcept(noexcept(_Pred(_Right, _Left))) /* strengthened */ {
// return smaller of _Left and _Right
return _Pred(_Right, _Left) ? _Right : _Left;
}
#pragma warning(push)
#pragma warning(disable : 28285) // (syntax error in SAL annotation, occurs when _Ty is not an integral type)
_EXPORT_STD template <class _Ty>
_NODISCARD _Post_equal_to_(_Right < _Left ? _Right : _Left) constexpr const _Ty& //
(min) (const _Ty& _Left _MSVC_LIFETIMEBOUND, const _Ty& _Right _MSVC_LIFETIMEBOUND)
noexcept(noexcept(_Right < _Left)) /* strengthened */ {
// return smaller of _Left and _Right
return _Right < _Left ? _Right : _Left;
}
#pragma warning(pop)
_EXPORT_STD template <class _Ty, class _Pr>
_NODISCARD constexpr _Ty(min)(initializer_list<_Ty>, _Pr); // implemented in <algorithm>
_EXPORT_STD template <class _Ty>
_NODISCARD constexpr _Ty(min)(initializer_list<_Ty>); // implemented in <algorithm>
_EXPORT_STD template <class _Ty, size_t _Size, enable_if_t<_Is_swappable<_Ty>::value, int> /* = 0 */>
_CONSTEXPR20 void swap(_Ty (&_Left)[_Size], _Ty (&_Right)[_Size]) noexcept(_Is_nothrow_swappable<_Ty>::value) {
if (&_Left == &_Right) {
return; // Handle self-swap as a no-op; see LWG-4165
}
if constexpr (_Is_trivially_swappable_v<_Ty>) {
if (!_STD _Is_constant_evaluated()) {
_STD _Swap_trivial_arrays(_Left, _Right);
return;
}
}
_Ty* _First1 = _Left;
_Ty* _Last1 = _First1 + _Size;
_Ty* _First2 = _Right;
for (; _First1 != _Last1; ++_First1, ++_First2) {
swap(*_First1, *_First2); // intentional ADL
}
}
#if _HAS_CXX17
_EXPORT_STD template <class _Ty, enable_if_t<is_move_constructible_v<_Ty> && is_move_assignable_v<_Ty>, int> /* = 0 */>
#else // ^^^ _HAS_CXX17 / !_HAS_CXX17 vvv
template <class _Ty, int _Enabled /* = 0 */>
#endif // ^^^ !_HAS_CXX17 ^^^
_CONSTEXPR20 void swap(_Ty& _Left, _Ty& _Right)
noexcept(is_nothrow_move_constructible_v<_Ty> && is_nothrow_move_assignable_v<_Ty>) {
_Ty _Tmp = _STD move(_Left);
_Left = _STD move(_Right);
_Right = _STD move(_Tmp);
}
_EXPORT_STD struct piecewise_construct_t { // tag type for pair tuple arguments
explicit piecewise_construct_t() = default;
};
_EXPORT_STD _INLINE_VAR constexpr piecewise_construct_t piecewise_construct{};
struct _Ignore { // struct that ignores assignments
template <class _Ty>
constexpr const _Ignore& operator=(const _Ty&) const noexcept {
// do nothing
return *this;
}
};
_EXPORT_STD _INLINE_VAR constexpr _Ignore ignore{};
_EXPORT_STD template <class... _Types>
class tuple;
_EXPORT_STD template <class _Ty1, class _Ty2>
struct pair;
_EXPORT_STD template <class _Ty, size_t _Size>
class array;
_EXPORT_STD template <class _Tuple>
struct tuple_size;
_EXPORT_STD template <class _Ty>
constexpr size_t tuple_size_v = tuple_size<_Ty>::value;
_EXPORT_STD template <size_t _Index, class _Tuple>
struct tuple_element;
_EXPORT_STD template <size_t _Index, class _Tuple>
using tuple_element_t = typename tuple_element<_Index, _Tuple>::type;
template <size_t _Index, class... _Types>
_NODISCARD constexpr auto&& _Tuple_get(tuple<_Types...>&& _Tuple) noexcept;
_EXPORT_STD template <size_t _Index, class... _Types>
_NODISCARD constexpr tuple_element_t<_Index, tuple<_Types...>>& get(tuple<_Types...>& _Tuple) noexcept;
_EXPORT_STD template <size_t _Index, class... _Types>
_NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>& get(const tuple<_Types...>& _Tuple) noexcept;
_EXPORT_STD template <size_t _Index, class... _Types>
_NODISCARD constexpr tuple_element_t<_Index, tuple<_Types...>>&& get(tuple<_Types...>&& _Tuple) noexcept;
_EXPORT_STD template <size_t _Index, class... _Types>
_NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const tuple<_Types...>&& _Tuple) noexcept;
_EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr _Ty& get(array<_Ty, _Size>& _Arr) noexcept;
_EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr const _Ty& get(const array<_Ty, _Size>& _Arr) noexcept;
_EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr _Ty&& get(array<_Ty, _Size>&& _Arr) noexcept;
_EXPORT_STD template <size_t _Idx, class _Ty, size_t _Size>
_NODISCARD constexpr const _Ty&& get(const array<_Ty, _Size>&& _Arr) noexcept;
#if _HAS_CXX20
template <class _Ty1, class _Ty2>
concept _Different_from = !same_as<remove_cvref_t<_Ty1>, remove_cvref_t<_Ty2>>;
template <class>
constexpr bool _Is_subrange_v = false;
#if _HAS_CXX23
template <class>
constexpr bool _Tuple_like_non_subrange_impl = false;
template <class... _Types>
constexpr bool _Tuple_like_non_subrange_impl<tuple<_Types...>> = true;
template <class _Ty1, class _Ty2>
constexpr bool _Tuple_like_non_subrange_impl<pair<_Ty1, _Ty2>> = true;
template <class _Ty, size_t _Size>
constexpr bool _Tuple_like_non_subrange_impl<array<_Ty, _Size>> = true;
template <class _Ty>
concept _Tuple_like_non_subrange = _Tuple_like_non_subrange_impl<remove_cvref_t<_Ty>>;
template <class _Ty>
concept _Tuple_like = _Tuple_like_non_subrange<_Ty> || _Is_subrange_v<remove_cvref_t<_Ty>>;
template <class _Ty>
concept _Pair_like_non_subrange = _Tuple_like_non_subrange<_Ty> && tuple_size_v<remove_cvref_t<_Ty>> == 2;
#ifdef __EDG__ // TRANSITION, VSO-1900279
template <class _PairLike, class _Ty1, class _Ty2>
concept _Can_construct_from_pair_like =
_Pair_like_non_subrange<_PairLike> && is_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_PairLike>()))>
&& is_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_PairLike>()))>;
#endif // ^^^ workaround ^^^
#endif // _HAS_CXX23
#endif // _HAS_CXX20
_EXPORT_STD template <class _Ty1, class _Ty2>
struct pair { // store a pair of values
using first_type = _Ty1;
using second_type = _Ty2;
template <class _Uty1 = _Ty1, class _Uty2 = _Ty2,
enable_if_t<conjunction_v<is_default_constructible<_Uty1>, is_default_constructible<_Uty2>>, int> = 0>
constexpr explicit(
!conjunction_v<_Is_implicitly_default_constructible<_Uty1>, _Is_implicitly_default_constructible<_Uty2>>) pair()
noexcept(is_nothrow_default_constructible_v<_Uty1> && is_nothrow_default_constructible_v<_Uty2>) // strengthened
: first(), second() {}
template <class _Uty1 = _Ty1, class _Uty2 = _Ty2,
enable_if_t<conjunction_v<is_copy_constructible<_Uty1>, is_copy_constructible<_Uty2>>, int> = 0>
constexpr explicit(!conjunction_v<is_convertible<const _Uty1&, _Uty1>, is_convertible<const _Uty2&, _Uty2>>)
pair(const _Ty1& _Val1, const _Ty2& _Val2)
noexcept(is_nothrow_copy_constructible_v<_Uty1> && is_nothrow_copy_constructible_v<_Uty2>) // strengthened
: first(_Val1), second(_Val2) {}
#if _HAS_CXX23
template <class _Other1 = _Ty1, class _Other2 = _Ty2,
#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv
template <class _Other1, class _Other2,
#endif // ^^^ !_HAS_CXX23 ^^^
enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>>, int> = 0>
constexpr explicit(!conjunction_v<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>)
pair(_Other1&& _Val1, _Other2&& _Val2) noexcept(
is_nothrow_constructible_v<_Ty1, _Other1> && is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
: first(_STD forward<_Other1>(_Val1)), second(_STD forward<_Other2>(_Val2)) {
}
pair(const pair&) = default;
pair(pair&&) = default;
#if _HAS_CXX23
template <class _Other1, class _Other2>
requires is_constructible_v<_Ty1, _Other1&> && is_constructible_v<_Ty2, _Other2&>
constexpr explicit(!conjunction_v<is_convertible<_Other1&, _Ty1>, is_convertible<_Other2&, _Ty2>>)
pair(pair<_Other1, _Other2>& _Right) noexcept(
is_nothrow_constructible_v<_Ty1, _Other1&> && is_nothrow_constructible_v<_Ty2, _Other2&>) // strengthened
: first(_Right.first), second(_Right.second) {}
#endif // _HAS_CXX23
template <class _Other1, class _Other2,
enable_if_t<conjunction_v<is_constructible<_Ty1, const _Other1&>, is_constructible<_Ty2, const _Other2&>>,
int> = 0>
constexpr explicit(!conjunction_v<is_convertible<const _Other1&, _Ty1>, is_convertible<const _Other2&, _Ty2>>)
pair(const pair<_Other1, _Other2>& _Right)
noexcept(is_nothrow_constructible_v<_Ty1, const _Other1&>
&& is_nothrow_constructible_v<_Ty2, const _Other2&>) // strengthened
: first(_Right.first), second(_Right.second) {}
template <class _Other1, class _Other2,
enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>>, int> = 0>
constexpr explicit(!conjunction_v<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>)
pair(pair<_Other1, _Other2>&& _Right) noexcept(
is_nothrow_constructible_v<_Ty1, _Other1> && is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
: first(_STD forward<_Other1>(_Right.first)), second(_STD forward<_Other2>(_Right.second)) {}
#if _HAS_CXX23
template <class _Other1, class _Other2>
requires is_constructible_v<_Ty1, const _Other1> && is_constructible_v<_Ty2, const _Other2>
constexpr explicit(!conjunction_v<is_convertible<const _Other1, _Ty1>, is_convertible<const _Other2, _Ty2>>)
pair(const pair<_Other1, _Other2>&& _Right)
noexcept(is_nothrow_constructible_v<_Ty1, const _Other1>
&& is_nothrow_constructible_v<_Ty2, const _Other2>) // strengthened
: first(_STD forward<const _Other1>(_Right.first)), second(_STD forward<const _Other2>(_Right.second)) {}
#ifdef __EDG__ // TRANSITION, VSO-1900279
template <class _Other, enable_if_t<_Can_construct_from_pair_like<_Other, _Ty1, _Ty2>, int> = 0>
#else // ^^^ workaround / no workaround vvv
template <_Pair_like_non_subrange _Other>
requires conjunction_v<is_constructible<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>,
is_constructible<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>>
#endif // ^^^ no workaround ^^^
constexpr explicit(!conjunction_v<is_convertible<decltype(_STD get<0>(_STD declval<_Other>())), _Ty1>,
is_convertible<decltype(_STD get<1>(_STD declval<_Other>())), _Ty2>>) pair(_Other&& _Right)
noexcept(is_nothrow_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_Other>()))>
&& is_nothrow_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_Other>()))>) // strengthened
: first(_STD get<0>(_STD forward<_Other>(_Right))), second(_STD get<1>(_STD forward<_Other>(_Right))) {
}
#endif // _HAS_CXX23
template <class... _Types1, class... _Types2>
_CONSTEXPR20 pair(piecewise_construct_t, tuple<_Types1...> _Val1, tuple<_Types2...> _Val2)
: pair(_Val1, _Val2, index_sequence_for<_Types1...>{}, index_sequence_for<_Types2...>{}) {}
pair& operator=(const volatile pair&) = delete;
template <class _Myself = pair,
enable_if_t<conjunction_v<_Is_copy_assignable_no_precondition_check<typename _Myself::first_type>,
_Is_copy_assignable_no_precondition_check<typename _Myself::second_type>>,
int> = 0>
_CONSTEXPR20 pair& operator=(_Identity_t<const _Myself&> _Right)
noexcept(conjunction_v<is_nothrow_copy_assignable<_Ty1>, is_nothrow_copy_assignable<_Ty2>>) /* strengthened */ {
first = _Right.first;
second = _Right.second;
return *this;
}
#if _HAS_CXX23
template <class _Myself = pair>
requires _Is_copy_assignable_unchecked_v<const typename _Myself::first_type>
&& _Is_copy_assignable_unchecked_v<const typename _Myself::second_type>
constexpr const pair& operator=(_Identity_t<const _Myself&> _Right) const
noexcept(conjunction_v<is_nothrow_copy_assignable<const _Ty1>,
is_nothrow_copy_assignable<const _Ty2>>) /* strengthened */ {
first = _Right.first;
second = _Right.second;
return *this;
}
#endif // _HAS_CXX23
template <class _Myself = pair,
enable_if_t<conjunction_v<_Is_move_assignable_no_precondition_check<typename _Myself::first_type>,
_Is_move_assignable_no_precondition_check<typename _Myself::second_type>>,
int> = 0>
_CONSTEXPR20 pair& operator=(_Identity_t<_Myself&&> _Right)
noexcept(conjunction_v<is_nothrow_move_assignable<_Ty1>, is_nothrow_move_assignable<_Ty2>>) /* strengthened */ {
first = _STD forward<_Ty1>(_Right.first);
second = _STD forward<_Ty2>(_Right.second);
return *this;
}
#if _HAS_CXX23
template <class _Myself = pair>
requires _Is_assignable_no_precondition_check<const typename _Myself::first_type&, _Ty1>::value
&& _Is_assignable_no_precondition_check<const typename _Myself::second_type&, _Ty2>::value
constexpr const pair& operator=(_Identity_t<_Myself&&> _Right) const
noexcept(conjunction_v<is_nothrow_assignable<const _Ty1&, _Ty1>,
is_nothrow_assignable<const _Ty2&, _Ty2>>) /* strengthened */ {
first = _STD forward<_Ty1>(_Right.first);
second = _STD forward<_Ty2>(_Right.second);
return *this;
}
#endif // _HAS_CXX23
template <class _Other1, class _Other2,
enable_if_t<conjunction_v<negation<is_same<pair, pair<_Other1, _Other2>>>, is_assignable<_Ty1&, const _Other1&>,
is_assignable<_Ty2&, const _Other2&>>,
int> = 0>
_CONSTEXPR20 pair& operator=(const pair<_Other1, _Other2>& _Right)
noexcept(is_nothrow_assignable_v<_Ty1&, const _Other1&>
&& is_nothrow_assignable_v<_Ty2&, const _Other2&>) /* strengthened */ {
first = _Right.first;
second = _Right.second;
return *this;
}
#if _HAS_CXX23
template <class _Other1, class _Other2>
requires (!is_same_v<pair, pair<_Other1, _Other2>>)
&& is_assignable_v<const _Ty1&, const _Other1&> && is_assignable_v<const _Ty2&, const _Other2&>
constexpr const pair& operator=(const pair<_Other1, _Other2>& _Right) const
noexcept(is_nothrow_assignable_v<const _Ty1&, const _Other1&>
&& is_nothrow_assignable_v<const _Ty2&, const _Other2&>) /* strengthened */ {
first = _Right.first;
second = _Right.second;
return *this;
}
#endif // _HAS_CXX23
template <class _Other1, class _Other2,
enable_if_t<conjunction_v<negation<is_same<pair, pair<_Other1, _Other2>>>, is_assignable<_Ty1&, _Other1>,
is_assignable<_Ty2&, _Other2>>,
int> = 0>
_CONSTEXPR20 pair& operator=(pair<_Other1, _Other2>&& _Right) noexcept(
is_nothrow_assignable_v<_Ty1&, _Other1> && is_nothrow_assignable_v<_Ty2&, _Other2>) /* strengthened */ {
first = _STD forward<_Other1>(_Right.first);
second = _STD forward<_Other2>(_Right.second);
return *this;
}
#if _HAS_CXX23
template <class _Other1, class _Other2>
requires (!is_same_v<pair, pair<_Other1, _Other2>>)
&& is_assignable_v<const _Ty1&, _Other1> && is_assignable_v<const _Ty2&, _Other2>
constexpr const pair& operator=(pair<_Other1, _Other2>&& _Right) const
noexcept(is_nothrow_assignable_v<const _Ty1&, _Other1>
&& is_nothrow_assignable_v<const _Ty2&, _Other2>) /* strengthened */ {
first = _STD forward<_Other1>(_Right.first);
second = _STD forward<_Other2>(_Right.second);
return *this;
}
template <_Pair_like_non_subrange _Other>
requires _Different_from<_Other, pair> && is_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>
&& is_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>
constexpr pair& operator=(_Other&& _Right)
noexcept(is_nothrow_assignable_v<_Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>
&& is_nothrow_assignable_v<_Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>) /* strengthened */ {
first = _STD get<0>(_STD forward<_Other>(_Right));
second = _STD get<1>(_STD forward<_Other>(_Right));
return *this;
}
template <_Pair_like_non_subrange _Other>
requires _Different_from<_Other, pair>
&& is_assignable_v<const _Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>
&& is_assignable_v<const _Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>
constexpr const pair& operator=(_Other&& _Right) const noexcept(
is_nothrow_assignable_v<const _Ty1&, decltype(_STD get<0>(_STD declval<_Other>()))>
&& is_nothrow_assignable_v<const _Ty2&, decltype(_STD get<1>(_STD declval<_Other>()))>) /* strengthened */ {
first = _STD get<0>(_STD forward<_Other>(_Right));
second = _STD get<1>(_STD forward<_Other>(_Right));
return *this;
}
#endif // _HAS_CXX23
_CONSTEXPR20 void swap(pair& _Right)
noexcept(_Is_nothrow_swappable<_Ty1>::value && _Is_nothrow_swappable<_Ty2>::value) {
using _STD swap;
swap(first, _Right.first); // intentional ADL
swap(second, _Right.second); // intentional ADL
}
#if _HAS_CXX23
template <int = 0> // see GH-3013
constexpr void swap(const pair& _Right) const
noexcept(is_nothrow_swappable_v<const _Ty1> && is_nothrow_swappable_v<const _Ty2>) {
using _STD swap;
swap(first, _Right.first); // intentional ADL
swap(second, _Right.second); // intentional ADL
}
#endif // _HAS_CXX23
_Ty1 first; // the first stored value
_Ty2 second; // the second stored value
private:
template <class _Tuple1, class _Tuple2, size_t... _Indices1, size_t... _Indices2>
constexpr pair(_Tuple1& _Val1, _Tuple2& _Val2, index_sequence<_Indices1...>, index_sequence<_Indices2...>)
: first(_STD _Tuple_get<_Indices1>(_STD move(_Val1))...),
second(_STD _Tuple_get<_Indices2>(_STD move(_Val2))...) {}
};
#if _HAS_CXX17
template <class _Ty1, class _Ty2>
pair(_Ty1, _Ty2) -> pair<_Ty1, _Ty2>;
#endif // _HAS_CXX17
_EXPORT_STD template <class _Ty1, class _Ty2,
enable_if_t<_Is_swappable<_Ty1>::value && _Is_swappable<_Ty2>::value, int> = 0>
_CONSTEXPR20 void swap(pair<_Ty1, _Ty2>& _Left, pair<_Ty1, _Ty2>& _Right) noexcept(noexcept(_Left.swap(_Right))) {
_Left.swap(_Right);
}
#if _HAS_CXX23
_EXPORT_STD template <class _Ty1, class _Ty2>
requires is_swappable<const _Ty1>::value && is_swappable<const _Ty2>::value // TRANSITION, /permissive needs ::value
constexpr void swap(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
noexcept(noexcept(_Left.swap(_Right))) {
_Left.swap(_Right);
}
#endif // _HAS_CXX23
_EXPORT_STD template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr bool operator==(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
return _Left.first == _Right.first && _Left.second == _Right.second;
}
#if _HAS_CXX20
_EXPORT_STD template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr common_comparison_category_t<_Synth_three_way_result<_Ty1, _Uty1>,
_Synth_three_way_result<_Ty2, _Uty2>>
operator<=>(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
if (auto _Result = _Synth_three_way{}(_Left.first, _Right.first); _Result != 0) {
return _Result;
}
return _Synth_three_way{}(_Left.second, _Right.second);
}
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr bool operator!=(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
return !(_Left == _Right);
}
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr bool operator<(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
return _Left.first < _Right.first || (!(_Right.first < _Left.first) && _Left.second < _Right.second);
}
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr bool operator>(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
return _Right < _Left;
}
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr bool operator<=(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
return !(_Right < _Left);
}
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
_NODISCARD constexpr bool operator>=(const pair<_Ty1, _Ty2>& _Left, const pair<_Uty1, _Uty2>& _Right) {
return !(_Left < _Right);
}
#endif // ^^^ !_HAS_CXX20 ^^^
#if _HAS_CXX23
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2, template <class> class _TQual,
template <class> class _UQual>
requires requires {
typename pair<common_reference_t<_TQual<_Ty1>, _UQual<_Uty1>>, common_reference_t<_TQual<_Ty2>, _UQual<_Uty2>>>;
}
struct basic_common_reference<pair<_Ty1, _Ty2>, pair<_Uty1, _Uty2>, _TQual, _UQual> {
using type = pair<common_reference_t<_TQual<_Ty1>, _UQual<_Uty1>>, common_reference_t<_TQual<_Ty2>, _UQual<_Uty2>>>;
};
template <class _Ty1, class _Ty2, class _Uty1, class _Uty2>
requires requires { typename pair<common_type_t<_Ty1, _Uty1>, common_type_t<_Ty2, _Uty2>>; }
struct common_type<pair<_Ty1, _Ty2>, pair<_Uty1, _Uty2>> {
using type = pair<common_type_t<_Ty1, _Uty1>, common_type_t<_Ty2, _Uty2>>;
};
#endif // _HAS_CXX23
template <class _Ty>
struct _Unrefwrap_helper { // leave unchanged if not a reference_wrapper
using type = _Ty;
};
template <class _Ty>
struct _Unrefwrap_helper<reference_wrapper<_Ty>> { // make a reference from a reference_wrapper
using type = _Ty&;
};
// decay, then unwrap a reference_wrapper
template <class _Ty>
using _Unrefwrap_t = typename _Unrefwrap_helper<decay_t<_Ty>>::type;
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr pair<_Unrefwrap_t<_Ty1>, _Unrefwrap_t<_Ty2>> make_pair(_Ty1&& _Val1, _Ty2&& _Val2)
noexcept(is_nothrow_constructible_v<_Unrefwrap_t<_Ty1>, _Ty1>
&& is_nothrow_constructible_v<_Unrefwrap_t<_Ty2>, _Ty2>) /* strengthened */ {
// return pair composed from arguments
using _Mypair = pair<_Unrefwrap_t<_Ty1>, _Unrefwrap_t<_Ty2>>;
return _Mypair(_STD forward<_Ty1>(_Val1), _STD forward<_Ty2>(_Val2));
}
namespace _CXX20_DEPRECATE_REL_OPS rel_ops {
_EXPORT_STD template <class _Ty>
_CXX20_DEPRECATE_REL_OPS _NODISCARD bool operator!=(const _Ty& _Left, const _Ty& _Right) {
return !(_Left == _Right);
}
_EXPORT_STD template <class _Ty>
_CXX20_DEPRECATE_REL_OPS _NODISCARD bool operator>(const _Ty& _Left, const _Ty& _Right) {
return _Right < _Left;
}
_EXPORT_STD template <class _Ty>
_CXX20_DEPRECATE_REL_OPS _NODISCARD bool operator<=(const _Ty& _Left, const _Ty& _Right) {
return !(_Right < _Left);
}
_EXPORT_STD template <class _Ty>
_CXX20_DEPRECATE_REL_OPS _NODISCARD bool operator>=(const _Ty& _Left, const _Ty& _Right) {
return !(_Left < _Right);
}
} // namespace _CXX20_DEPRECATE_REL_OPS rel_ops
template <class _Tuple, class = void>
struct _Tuple_size_sfinae {}; // selected when tuple_size<_Tuple>::value isn't well-formed
template <class _Tuple>
struct _Tuple_size_sfinae<_Tuple, void_t<decltype(tuple_size<_Tuple>::value)>>
: integral_constant<size_t, tuple_size<_Tuple>::value> {}; // selected when tuple_size<_Tuple>::value is well-formed
template <class _Tuple>
struct tuple_size<const _Tuple> : _Tuple_size_sfinae<_Tuple> {}; // ignore cv
template <class _Tuple>
struct _CXX20_DEPRECATE_VOLATILE tuple_size<volatile _Tuple> : _Tuple_size_sfinae<_Tuple> {}; // ignore cv
template <class _Tuple>
struct _CXX20_DEPRECATE_VOLATILE tuple_size<const volatile _Tuple> : _Tuple_size_sfinae<_Tuple> {}; // ignore cv
template <size_t _Index, class _Tuple>
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Index, const _Tuple> : tuple_element<_Index, _Tuple> {
using _Mybase = tuple_element<_Index, _Tuple>;
using type = add_const_t<typename _Mybase::type>;
};
template <size_t _Index, class _Tuple>
struct _CXX20_DEPRECATE_VOLATILE _MSVC_KNOWN_SEMANTICS tuple_element<_Index, volatile _Tuple>
: tuple_element<_Index, _Tuple> {
using _Mybase = tuple_element<_Index, _Tuple>;
using type = add_volatile_t<typename _Mybase::type>;
};
template <size_t _Index, class _Tuple>
struct _CXX20_DEPRECATE_VOLATILE _MSVC_KNOWN_SEMANTICS tuple_element<_Index, const volatile _Tuple>
: tuple_element<_Index, _Tuple> {
using _Mybase = tuple_element<_Index, _Tuple>;
using type = add_cv_t<typename _Mybase::type>;
};
template <class _Ty, size_t _Size>
struct tuple_size<array<_Ty, _Size>> : integral_constant<size_t, _Size> {}; // size of array
template <size_t _Idx, class _Ty, size_t _Size>
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Idx, array<_Ty, _Size>> {
static_assert(_Idx < _Size, "array index out of bounds");
using type = _Ty;
};
template <class... _Types>
struct tuple_size<tuple<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {}; // size of tuple
template <size_t _Index>
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Index, tuple<>> { // enforce bounds checking
static_assert(_Always_false<integral_constant<size_t, _Index>>, "tuple index out of bounds");
};
template <class _This, class... _Rest>
struct _MSVC_KNOWN_SEMANTICS tuple_element<0, tuple<_This, _Rest...>> { // select first element
using type = _This;
// MSVC assumes the meaning of _Ttype; remove or rename, but do not change semantics
using _Ttype = tuple<_This, _Rest...>;
};
template <size_t _Index, class _This, class... _Rest>
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Index, tuple<_This, _Rest...>>
: tuple_element<_Index - 1, tuple<_Rest...>> {}; // recursive tuple_element definition
template <class _Ty1, class _Ty2>
struct tuple_size<pair<_Ty1, _Ty2>> : integral_constant<size_t, 2> {}; // size of pair
template <size_t _Idx, class _Ty1, class _Ty2>
struct _MSVC_KNOWN_SEMANTICS tuple_element<_Idx, pair<_Ty1, _Ty2>> {
static_assert(_Idx < 2, "pair index out of bounds");
using type = conditional_t<_Idx == 0, _Ty1, _Ty2>;
};
_EXPORT_STD template <size_t _Idx, class _Ty1, class _Ty2>
_NODISCARD constexpr tuple_element_t<_Idx, pair<_Ty1, _Ty2>>& get(pair<_Ty1, _Ty2>& _Pr) noexcept {
// get reference to element at _Idx in pair _Pr
if constexpr (_Idx == 0) {
return _Pr.first;
} else {
return _Pr.second;
}
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr _Ty1& get(pair<_Ty1, _Ty2>& _Pr) noexcept {
// get reference to element _Ty1 in pair _Pr
return _Pr.first;
}
_EXPORT_STD template <class _Ty2, class _Ty1>
_NODISCARD constexpr _Ty2& get(pair<_Ty1, _Ty2>& _Pr) noexcept {
// get reference to element _Ty2 in pair _Pr
return _Pr.second;
}
_EXPORT_STD template <size_t _Idx, class _Ty1, class _Ty2>
_NODISCARD constexpr const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>& get(const pair<_Ty1, _Ty2>& _Pr) noexcept {
// get const reference to element at _Idx in pair _Pr
if constexpr (_Idx == 0) {
return _Pr.first;
} else {
return _Pr.second;
}
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr const _Ty1& get(const pair<_Ty1, _Ty2>& _Pr) noexcept {
// get const reference to element _Ty1 in pair _Pr
return _Pr.first;
}
_EXPORT_STD template <class _Ty2, class _Ty1>
_NODISCARD constexpr const _Ty2& get(const pair<_Ty1, _Ty2>& _Pr) noexcept {
// get const reference to element _Ty2 in pair _Pr
return _Pr.second;
}
_EXPORT_STD template <size_t _Idx, class _Ty1, class _Ty2>
_NODISCARD constexpr tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept {
// get rvalue reference to element at _Idx in pair _Pr
if constexpr (_Idx == 0) {
return _STD forward<_Ty1>(_Pr.first);
} else {
return _STD forward<_Ty2>(_Pr.second);
}
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr _Ty1&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept {
// get rvalue reference to element _Ty1 in pair _Pr
return _STD forward<_Ty1>(_Pr.first);
}
_EXPORT_STD template <class _Ty2, class _Ty1>
_NODISCARD constexpr _Ty2&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept {
// get rvalue reference to element _Ty2 in pair _Pr
return _STD forward<_Ty2>(_Pr.second);
}
_EXPORT_STD template <size_t _Idx, class _Ty1, class _Ty2>
_NODISCARD constexpr const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept {
// get const rvalue reference to element at _Idx in pair _Pr
if constexpr (_Idx == 0) {
return _STD forward<const _Ty1>(_Pr.first);
} else {
return _STD forward<const _Ty2>(_Pr.second);
}
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr const _Ty1&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept {
// get const rvalue reference to element _Ty1 in pair _Pr
return _STD forward<const _Ty1>(_Pr.first);
}
_EXPORT_STD template <class _Ty2, class _Ty1>
_NODISCARD constexpr const _Ty2&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept {
// get const rvalue reference to element _Ty2 in pair _Pr
return _STD forward<const _Ty2>(_Pr.second);
}
_EXPORT_STD template <class _Ty, class _Other = _Ty>
_CONSTEXPR20 _Ty exchange(_Ty& _Val, _Other&& _New_val)
noexcept(conjunction_v<is_nothrow_move_constructible<_Ty>, is_nothrow_assignable<_Ty&, _Other>>) {
// assign _New_val to _Val, return previous _Val
_Ty _Old_val = static_cast<_Ty&&>(_Val);
_Val = static_cast<_Other&&>(_New_val);
return _Old_val;
}
_EXPORT_STD template <class _Ty>
_NODISCARD _MSVC_INTRINSIC constexpr add_const_t<_Ty>& as_const(_Ty& _Val) noexcept { // view _Val through const lenses
return _Val;
}
_EXPORT_STD template <class _Ty>
void as_const(const _Ty&&) = delete;
#if _HAS_CXX17
_EXPORT_STD struct in_place_t { // tag used to select a constructor which initializes a contained object in place
explicit in_place_t() = default;
};
_EXPORT_STD inline constexpr in_place_t in_place{};
_EXPORT_STD template <class>
struct in_place_type_t { // tag that selects a type to construct in place
explicit in_place_type_t() = default;
};
_EXPORT_STD template <class _Ty>
constexpr in_place_type_t<_Ty> in_place_type{};
_EXPORT_STD template <size_t>
struct in_place_index_t { // tag that selects the index of a type to construct in place
explicit in_place_index_t() = default;
};
_EXPORT_STD template <size_t _Idx>
constexpr in_place_index_t<_Idx> in_place_index{};
#endif // _HAS_CXX17
template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool _Cmp_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
_STL_INTERNAL_STATIC_ASSERT(_Is_nonbool_integral<_Ty1> && _Is_nonbool_integral<_Ty2>); // allows character types
if constexpr (is_signed_v<_Ty1> == is_signed_v<_Ty2>) {
return _Left == _Right;
} else if constexpr (is_signed_v<_Ty2>) {
return _Left == static_cast<make_unsigned_t<_Ty2>>(_Right) && _Right >= 0;
} else {
return static_cast<make_unsigned_t<_Ty1>>(_Left) == _Right && _Left >= 0;
}
}
template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool _Cmp_not_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
return !_STD _Cmp_equal(_Left, _Right);
}
template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool _Cmp_less(const _Ty1 _Left, const _Ty2 _Right) noexcept {
_STL_INTERNAL_STATIC_ASSERT(_Is_nonbool_integral<_Ty1> && _Is_nonbool_integral<_Ty2>); // allows character types
if constexpr (is_signed_v<_Ty1> == is_signed_v<_Ty2>) {
return _Left < _Right;
} else if constexpr (is_signed_v<_Ty2>) {
return _Right > 0 && _Left < static_cast<make_unsigned_t<_Ty2>>(_Right);
} else {
return _Left < 0 || static_cast<make_unsigned_t<_Ty1>>(_Left) < _Right;
}
}
template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool _Cmp_greater(const _Ty1 _Left, const _Ty2 _Right) noexcept {
return _STD _Cmp_less(_Right, _Left);
}
template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool _Cmp_less_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
return !_STD _Cmp_less(_Right, _Left);
}
template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool _Cmp_greater_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
return !_STD _Cmp_less(_Left, _Right);
}
template <class _Ty>
_NODISCARD constexpr _Ty _Min_limit() noexcept { // same as (numeric_limits<_Ty>::min)(), less throughput cost
_STL_INTERNAL_STATIC_ASSERT(is_integral_v<_Ty>); // doesn't attempt to handle all types
if constexpr (is_signed_v<_Ty>) {
constexpr auto _Unsigned_max = static_cast<make_unsigned_t<_Ty>>(-1);
return static_cast<_Ty>((_Unsigned_max >> 1) + 1); // well-defined, N4950 [conv.integral]/3
} else {
return 0;
}
}
template <class _Ty>
_NODISCARD constexpr _Ty _Max_limit() noexcept { // same as (numeric_limits<_Ty>::max)(), less throughput cost
_STL_INTERNAL_STATIC_ASSERT(is_integral_v<_Ty>); // doesn't attempt to handle all types
if constexpr (is_signed_v<_Ty>) {
constexpr auto _Unsigned_max = static_cast<make_unsigned_t<_Ty>>(-1);
return static_cast<_Ty>(_Unsigned_max >> 1);
} else {
return static_cast<_Ty>(-1);
}
}
template <class _Rx, class _Ty>
_NODISCARD constexpr bool _In_range(const _Ty _Value) noexcept {
_STL_INTERNAL_STATIC_ASSERT(_Is_nonbool_integral<_Rx> && _Is_nonbool_integral<_Ty>); // allows character types
constexpr auto _Ty_min = _Min_limit<_Ty>();
constexpr auto _Rx_min = _Min_limit<_Rx>();
if constexpr (_STD _Cmp_less(_Ty_min, _Rx_min)) {
if (_Value < _Ty{_Rx_min}) {
return false;
}
}
constexpr auto _Ty_max = _Max_limit<_Ty>();
constexpr auto _Rx_max = _Max_limit<_Rx>();
if constexpr (_STD _Cmp_greater(_Ty_max, _Rx_max)) {
if (_Value > _Ty{_Rx_max}) {
return false;
}
}
return true;
}
#if _HAS_CXX20
template <class _Ty>
constexpr bool _Is_standard_integer = _Is_any_of_v<remove_cv_t<_Ty>, signed char, short, int, long, long long,
unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long>;
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool cmp_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
static_assert(_Is_standard_integer<_Ty1> && _Is_standard_integer<_Ty2>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _Cmp_equal(_Left, _Right);
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool cmp_not_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
static_assert(_Is_standard_integer<_Ty1> && _Is_standard_integer<_Ty2>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _Cmp_not_equal(_Left, _Right);
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool cmp_less(const _Ty1 _Left, const _Ty2 _Right) noexcept {
static_assert(_Is_standard_integer<_Ty1> && _Is_standard_integer<_Ty2>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _Cmp_less(_Left, _Right);
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool cmp_greater(const _Ty1 _Left, const _Ty2 _Right) noexcept {
static_assert(_Is_standard_integer<_Ty1> && _Is_standard_integer<_Ty2>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _Cmp_greater(_Left, _Right);
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool cmp_less_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
static_assert(_Is_standard_integer<_Ty1> && _Is_standard_integer<_Ty2>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _Cmp_less_equal(_Left, _Right);
}
_EXPORT_STD template <class _Ty1, class _Ty2>
_NODISCARD constexpr bool cmp_greater_equal(const _Ty1 _Left, const _Ty2 _Right) noexcept {
static_assert(_Is_standard_integer<_Ty1> && _Is_standard_integer<_Ty2>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _Cmp_greater_equal(_Left, _Right);
}
_EXPORT_STD template <class _Rx, class _Ty>
_NODISCARD constexpr bool in_range(const _Ty _Value) noexcept {
static_assert(_Is_standard_integer<_Rx> && _Is_standard_integer<_Ty>,
"The integer comparison functions only accept standard and extended integer types.");
return _STD _In_range<_Rx>(_Value);
}
#endif // _HAS_CXX20
#if _HAS_CXX23
_EXPORT_STD template <class _Ty>
_NODISCARD _MSVC_INTRINSIC constexpr underlying_type_t<_Ty> to_underlying(_Ty _Value) noexcept {
return static_cast<underlying_type_t<_Ty>>(_Value);
}
_EXPORT_STD [[noreturn]] __forceinline void unreachable() noexcept /* strengthened */ {
_STL_UNREACHABLE;
#ifdef _DEBUG
_CSTD abort(); // likely to be called in debug mode, but can't be relied upon - already entered the UB territory
#endif // defined(_DEBUG)
}
template <class _Ty, class _Uty,
class _Tmp = _Maybe_const<is_const_v<remove_reference_t<_Ty>>, remove_reference_t<_Uty>>>
using _Forward_like_t = conditional_t<is_rvalue_reference_v<_Ty&&>, _Tmp&&, _Tmp&>;
_EXPORT_STD template <class _Ty, class _Uty>
_NODISCARD _MSVC_INTRINSIC constexpr _Forward_like_t<_Ty, _Uty> forward_like(_Uty&& _Ux) noexcept {
return static_cast<_Forward_like_t<_Ty, _Uty>>(_Ux);
}
#endif // _HAS_CXX23
#if _HAS_TR1_NAMESPACE
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
using _STD get;
using _STD tuple_element;
using _STD tuple_size;
} // namespace _DEPRECATE_TR1_NAMESPACE tr1
#endif // _HAS_TR1_NAMESPACE
_STD_END
// TRANSITION, non-_Ugly attribute tokens
#pragma pop_macro("lifetimebound")
#pragma pop_macro("known_semantics")
#pragma pop_macro("intrinsic")
#pragma pop_macro("msvc")
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _UTILITY_