forked from zufuliu/notepad4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPP.cpp
4264 lines (4043 loc) · 169 KB
/
CPP.cpp
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
// C++11 https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
// C++14 https://github.com/cplusplus/draft/blob/main/papers/n4140.pdf
// C++17 https://open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf
// C++20 https://open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4868.pdf
// C++23 https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf
// https://en.cppreference.com/w/cpp
// https://en.cppreference.com/w/cpp/header
// https://en.cppreference.com/w/cpp/links
alignas alignof asm
break case catch class const const_cast constexpr constinit continue
decltype default delete do dynamic_cast
else enum explicit export extern
false for friend goto
if inline
mutable
namespace new noexcept nullptr
operator
private protected public
register reinterpret_cast return
sizeof static static_assert static_cast struct switch
template this thread_local throw true try typedef typeid typename
union using
volatile
while
override final
auto bool char char16_t char32_t double float int long short signed unsigned wchar_t void
and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq
// Conditional inclusion
__has_include(header)
__has_cpp_attribute(pp-tokens)
// Argument substitution
__VA_OPT__
// Predefined macro names
__cplusplus
__STDCPP_DEFAULT_NEW_ALIGNMENT__
// Feature-test macros
__STDCPP_STRICT_POINTER_SAFETY__
__STDCPP_THREADS__
#include <cstddef>
namespace std { // Common definitions
nullptr_t = decltype(nullptr);
enum class byte : unsigned char {};
template <class IntType>
constexpr IntType to_integer(byte b) noexcept;
}
// Implementation properties
#include <version> // C++20
#include <limits>
namespace std { // Implementation properties
enum float_round_style {
round_indeterminate,
round_toward_zero,
round_to_nearest,
round_toward_infinity,
round_toward_neg_infinity,
};
enum float_denorm_style {
denorm_indeterminate,
denorm_absent,
denorm_present,
};
template <class T>
class numeric_limits {
bool is_specialized;
T min();
T max();
T lowest();
int digits;
int digits10;
int max_digits10;
bool is_signed;
bool is_integer;
bool is_exact;
int radix;
T epsilon();
T round_error();
int min_exponent;
int min_exponent10;
int max_exponent;
int max_exponent10;
bool has_infinity;
bool has_quiet_NaN;
bool has_signaling_NaN;
float_denorm_style has_denorm;
bool has_denorm_loss;
T infinity();
T quiet_NaN();
T signaling_NaN();
T denorm_min();
bool is_iec559;
bool is_bounded;
bool is_modulo;
bool traps;
bool tinyness_before;
float_round_style round_style;
};
}
#include <new>
namespace std { // Dynamic memory management
class bad_alloc : public exception {};
class bad_array_new_length : public bad_alloc {};
struct destroying_delete_t { // C++20
explicit destroying_delete_t() = default;
};
inline constexpr destroying_delete_t destroying_delete {}; //C++20
enum class align_val_t : size_t {};
struct nothrow_t {};
extern const nothrow_t nothrow;
using new_handler = void (*)();
new_handler get_new_handler() noexcept;
new_handler set_new_handler(new_handler new_p) noexcept;
template <class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;
size_t hardware_destructive_interference_size;
size_t hardware_constructive_interference_size;
[[nodiscard]] void* operator new(size_t size);
void operator delete(void* ptr) noexcept;
[[nodiscard]] void* operator new[](std::size_t size);
void operator delete[](void* ptr) noexcept;
}
#include <typeinfo>
namespace std { // Type identification
class type_info {
bool before(const type_info& rhs) const noexcept;
size_t hash_code() const noexcept;
const char* name() const noexcept;
};
class bad_cast : public exception {};
class bad_typeid : public exception {};
}
#include <source_location> // C++20
namespace std { // Source location
struct source_location {
static consteval source_location current() noexcept;
constexpr uint_least32_t line() const noexcept;
constexpr uint_least32_t column() const noexcept;
constexpr const char* file_name() const noexcept;
constexpr const char* function_name() const noexcept;
};
}
#include <contract> // C++2x
namespace std { // Contract violation handling
class contract_violation {
uint_least32_t line_number() const noexcept;
string_view file_name() const noexcept;
string_view function_name() const noexcept;
string_view comment() const noexcept;
string_view assertion_level() const noexcept;
};
}
#include <compare> // C++20
namespace std { // Comparisons
class partial_ordering {
static const partial_ordering less;
static const partial_ordering equivalent;
static const partial_ordering greater;
static const partial_ordering unordered;
};
class weak_ordering {
static const weak_ordering less;
static const weak_ordering equivalent;
static const weak_ordering greater;
};
class strong_ordering {
static const strong_ordering less;
static const strong_ordering equal;
static const strong_ordering equivalent;
static const strong_ordering greater;
};
constexpr bool is_eq(partial_ordering cmp) noexcept { return cmp == 0; }
constexpr bool is_neq(partial_ordering cmp) noexcept { return cmp != 0; }
constexpr bool is_lt(partial_ordering cmp) noexcept { return cmp < 0; }
constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
constexpr bool is_gt(partial_ordering cmp) noexcept { return cmp > 0; }
constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
template <class... Ts>
struct common_comparison_category {
using type;
};
template <class... Ts>
using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
template <class T, class Cat = partial_ordering>
concept three_way_comparable;
template <class T, class U, class Cat = partial_ordering>
concept three_way_comparable_with;
template <class T, class U = T>
struct compare_three_way_result;
template <class T, class U = T>
using compare_three_way_result_t = typename compare_three_way_result<T, U>::type;
struct compare_three_way {
using is_transparent;
};
inline namespace {
inline constexpr strong_order(E, F);
inline constexpr weak_order(E, F);
inline constexpr partial_order(E, F);
inline constexpr compare_strong_order_fallback(E, F);
inline constexpr compare_weak_order_fallback(E, F);
inline constexpr compare_partial_order_fallback(E, F);
}
}
#include <coroutine> // C++20
namespace std { // Coroutines
template <class R, class... ArgTypes>
struct coroutine_traits {
using promise_type = typename R::promise_type;
};
template <>
struct coroutine_handle<void> {
constexpr void* address() const noexcept;
static constexpr coroutine_handle from_address(void* addr);
bool done() const;
void resume() const;
void destroy() const;
};
template <class Promise>
struct coroutine_handle : coroutine_handle<> {
using coroutine_handle<>::coroutine_handle;
static coroutine_handle from_promise(Promise&);
static constexpr coroutine_handle from_address(void* addr);
Promise& promise() const;
};
struct noop_coroutine_promise;
template <> struct coroutine_handle<noop_coroutine_promise> : coroutine_handle<> {
constexpr bool done() const noexcept;
constexpr void resume() const noexcept;
constexpr void destroy() const noexcept;
noop_coroutine_promise& promise() const noexcept;
constexpr void* address() const noexcept;
};
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
noop_coroutine_handle noop_coroutine() noexcept;
struct suspend_never {
constexpr bool await_ready() const noexcept { return true; }
constexpr void await_suspend(coroutine_handle<>) const noexcept {}
constexpr void await_resume() const noexcept {}
};
struct suspend_always;
}
#include <concepts> // C++20
namespace std { // Concepts
// language-related concepts
template <class T, class U>
concept same_as;
template <class Derived, class Base>
concept derived_from ;
template <class From, class To>
concept convertible_to;
template <class T, class U>
concept common_reference_with;
template <class T, class U>
concept common_with;
template <class T>
concept integral;
template <class T>
concept signed_integral;
template <class T>
concept unsigned_integral;
template <class T>
concept floating_point;
template <class LHS, class RHS>
concept assignable_from;
template <class T>
concept swappable;
template <class T, class U>
concept swappable_with;
template <class T>
concept destructible;
template <class T, class... Args>
concept constructible_from;
template <class T>
concept default_initializable;
template <class T>
concept move_constructible;
template <class T>
concept copy_constructible ;
// comparison concepts
template <class T>
concept equality_comparable;
template <class T, class U>
concept equality_comparable_with;
template <class T>
concept totally_ordered;
template <class T, class U>
concept totally_ordered_with;
// object concepts
template <class T>
concept movable;
template <class T>
concept copyable;
template <class T>
concept semiregular;
template <class T>
concept regular;
// callable concepts
template <class F, class... Args>
concept invocable;
template <class F, class... Args>
concept regular_invocable;
template <class F, class... Args>
concept predicate;
template <class R, class T, class U>
concept relation;
template <class R, class T, class U>
concept strict_weak_order;
}
#include <exception>
namespace std { // Exception handling
class exception {
const char* what() const noexcept;
}
class bad_exception : public exception {};
class nested_exception {
[[noreturn]] void rethrow_nested() const;
exception_ptr nested_ptr() const noexcept;
};
using terminate_handler = void (*)();
terminate_handler get_terminate() noexcept;
terminate_handler set_terminate(terminate_handler f) noexcept;
[[noreturn]] void terminate() noexcept;
int uncaught_exceptions() noexcept;
using exception_ptr;
exception_ptr current_exception() noexcept;
[[noreturn]] void rethrow_exception(exception_ptr p);
template <class E> exception_ptr make_exception_ptr(E e) noexcept;
template <class T> [[noreturn]] void throw_with_nested(T&& t);
template <class E> void rethrow_if_nested(const E& e);
}
#include <initializer_list>
namespace std { // Initializer lists
template <class E>
class initializer_list {
using value_type = E;
using reference = const E&;
using const_reference = const E&;
using size_type = size_t;
using iterator = const E*;
using const_iterator = const E*;
constexpr size_t size() const noexcept;
constexpr const E* begin() const noexcept;
constexpr const E* end() const noexcept;
};
}
#include <stdexcept>
namespace std { // Exception classes
class logic_error : public exception {};
class domain_error : public logic_error {};
class invalid_argument : public logic_error {};
class length_error : public logic_error {};
class out_of_range : public logic_error {};
class runtime_error : public exception {};
class range_error : public runtime_error {};
class overflow_error : public runtime_error {};
class underflow_error : public runtime_error {};
}
#include <system_error>
namespace std { // System error support
class error_category {
const char* name() const noexcept = 0;
error_condition default_error_condition(int ev) const noexcept;
bool equivalent(int code, const error_condition& condition) const noexcept;
bool equivalent(const error_code& code, int condition) const noexcept;
string message(int ev) const = 0;
};
const error_category& generic_category() noexcept;
const error_category& system_category() noexcept;
class error_code {
void assign(int val, const error_category& cat) noexcept;
void clear() noexcept;
int value() const noexcept;
const error_category& category() const noexcept;
error_condition default_error_condition() const noexcept;
string message() const;
};
class error_condition {
void assign(int val, const error_category& cat) noexcept;
void clear() noexcept;
int value() const noexcept;
const error_category& category() const noexcept;
string message() const;
};
class system_error : public runtime_error {
const error_code& code() const noexcept;
};
template <class T>
struct is_error_code_enum : public false_type {};
template <class T>
struct is_error_condition_enum : public false_type {};
enum class errc {
address_family_not_supported, // EAFNOSUPPORT
address_in_use, // EADDRINUSE
address_not_available, // EADDRNOTAVAIL
already_connected, // EISCONN
argument_list_too_long, // E2BIG
argument_out_of_domain, // EDOM
bad_address, // EFAULT
bad_file_descriptor, // EBADF
bad_message, // EBADMSG
broken_pipe, // EPIPE
connection_aborted, // ECONNABORTED
connection_already_in_progress, // EALREADY
connection_refused, // ECONNREFUSED
connection_reset, // ECONNRESET
cross_device_link, // EXDEV
destination_address_required, // EDESTADDRREQ
device_or_resource_busy, // EBUSY
directory_not_empty, // ENOTEMPTY
executable_format_error, // ENOEXEC
file_exists, // EEXIST
file_too_large, // EFBIG
filename_too_long, // ENAMETOOLONG
function_not_supported, // ENOSYS
host_unreachable, // EHOSTUNREACH
identifier_removed, // EIDRM
illegal_byte_sequence, // EILSEQ
inappropriate_io_control_operation, // ENOTTY
interrupted, // EINTR
invalid_argument, // EINVAL
invalid_seek, // ESPIPE
io_error, // EIO
is_a_directory, // EISDIR
message_size, // EMSGSIZE
network_down, // ENETDOWN
network_reset, // ENETRESET
network_unreachable, // ENETUNREACH
no_buffer_space, // ENOBUFS
no_child_process, // ECHILD
no_link, // ENOLINK
no_lock_available, // ENOLCK
no_message_available, // ENODATA
no_message, // ENOMSG
no_protocol_option, // ENOPROTOOPT
no_space_on_device, // ENOSPC
no_stream_resources, // ENOSR
no_such_device_or_address, // ENXIO
no_such_device, // ENODEV
no_such_file_or_directory, // ENOENT
no_such_process, // ESRCH
not_a_directory, // ENOTDIR
not_a_socket, // ENOTSOCK
not_a_stream, // ENOSTR
not_connected, // ENOTCONN
not_enough_memory, // ENOMEM
not_supported, // ENOTSUP
operation_canceled, // ECANCELED
operation_in_progress, // EINPROGRESS
operation_not_permitted, // EPERM
operation_not_supported, // EOPNOTSUPP
operation_would_block, // EWOULDBLOCK
owner_dead, // EOWNERDEAD
permission_denied, // EACCES
protocol_error, // EPROTO
protocol_not_supported, // EPROTONOSUPPORT
read_only_file_system, // EROFS
resource_deadlock_would_occur, // EDEADLK
resource_unavailable_try_again, // EAGAIN
result_out_of_range, // ERANGE
state_not_recoverable, // ENOTRECOVERABLE
stream_timeout, // ETIME
text_file_busy, // ETXTBSY
timed_out, // ETIMEDOUT
too_many_files_open_in_system, // ENFILE
too_many_files_open, // EMFILE
too_many_links, // EMLINK
too_many_symbolic_link_levels, // ELOOP
value_too_large, // EOVERFLOW
wrong_protocol_type, // EPROTOTYPE
};
template <> struct is_error_condition_enum<errc> : true_type {};
error_code make_error_code(errc e) noexcept;
error_condition make_error_condition(errc e) noexcept;
template <class T> struct hash;
template <> struct hash<error_code>;
template <> struct hash<error_condition>;
template <class T> inline constexpr bool is_error_code_enum_v = is_error_code_enum<T>::value;
template <class T> inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<T>::value;
}
#include <utility>
namespace std { // Utility components
namespace rel_ops {}
template <class T> void swap(T& a, T& b) noexcept();
template <class T, size_t N> void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v<T>);
template <class T, class U = T> T exchange(T& obj, U&& new_val);
// Forward/move helpers
template <class T> constexpr T&& forward(remove_reference_t<T>& t) noexcept;
template <class T> constexpr T&& forward(remove_reference_t<T>&& t) noexcept;
template <class T> constexpr remove_reference_t<T>&& move(T&&) noexcept;
template <class T> constexpr conditional_t<!is_nothrow_move_constructible_v<T> && is_copy_constructible_v<T>, const T&, T&&>
move_if_noexcept(T& x) noexcept;
template <class T> constexpr add_const_t<T>& as_const(T& t) noexcept;
template <class T> void as_const(const T&&) = delete;
template <class T> add_rvalue_reference_t<T> declval() noexcept;
// Integer comparison functions
template<class T, class U> constexpr bool cmp_equal(T t, U u) noexcept;
template<class T, class U> constexpr bool cmp_not_equal(T t, U u) noexcept;
template<class T, class U> constexpr bool cmp_less(T t, U u) noexcept;
template<class T, class U> constexpr bool cmp_greater(T t, U u) noexcept;
template<class T, class U> constexpr bool cmp_less_equal(T t, U u) noexcept;
template<class T, class U> constexpr bool cmp_greater_equal(T t, U u) noexcept;
template<class R, class T> constexpr bool in_range(T t) noexcept;
// Compile-time integer sequences
template <class T, T...>
struct integer_sequence {
using value_type = T;
size_t size();
};
template <size_t... I> using index_sequence = integer_sequence<size_t, I...>;
template <class T, T N> using make_integer_sequence = integer_sequence<T,>;
template <size_t N> using make_index_sequence = make_integer_sequence<size_t, N>;
template <class... T> using index_sequence_for = make_index_sequence<sizeof...(T)>;
// Pairs
template <class T1, class T2>
struct pair {
using first_type;
using second_type;
T1 first;
T2 second;
};
template <class T1, class T2> constexpr make_pair(T1&&, T2&&);
template <class T> class tuple_size;
template <size_t I, class T> class tuple_element;
template <size_t I, class T1, class T2>
constexpr tuple_element_t<I, pair<T1, T2>>& get(pair<T1, T2>&) noexcept;
// Piecewise construction
struct piecewise_construct_t {
explicit piecewise_construct_t() = default;
};
inline constexpr piecewise_construct_t piecewise_construct{};
struct in_place_t {
explicit in_place_t() = default;
};
inline constexpr in_place_t in_place{};
template <class T>
struct in_place_type_t {
explicit in_place_type_t() = default;
};
template <class T> inline constexpr in_place_type_t<T> in_place_type{};
template <size_t I>
struct in_place_index_t {
explicit in_place_index_t() = default;
};
template <size_t I> inline constexpr in_place_index_t<I> in_place_index{};
}
#include <tuple>
namespace std { // Tuples
template <class... Types> class tuple {};
inline constexpr ignore;
template <class... TTypes> constexpr tuple<VTypes...> make_tuple(TTypes&&...);
template <class... TTypes> constexpr tuple<TTypes&&...> forward_as_tuple(TTypes&&...) noexcept;
template <class... TTypes> constexpr tuple<TTypes&...> tie(TTypes&...) noexcept;
template <class... Tuples> constexpr tuple<CTypes...> tuple_cat(Tuples&&...);
template <class F, class Tuple> constexpr decltype(auto) apply(F&& f, Tuple&& t);
template <class T, class Tuple> constexpr T make_from_tuple(Tuple&& t);
template <class... Types, class Alloc>
struct uses_allocator<tuple<Types...>, Alloc>;
template <class T> inline constexpr size_t tuple_size_v = tuple_size<T>::value;
}
#include <optional>
namespace std { // Optional objects
template <class T>
class optional {
using value_type = T;
template <class... Args> T& emplace(Args&&...);
constexpr bool has_value() const noexcept;
constexpr const T& value() const&;
template <class U> constexpr T value_or(U&&) const&;
void reset() noexcept;
};
struct nullopt_t {};
inline constexpr nullopt_t nullopt();
class bad_optional_access : public exception {};
template <class T> constexpr optional<> make_optional(T&&);
template <class T, class... Args> constexpr optional<T> make_optional(Args&&... args);
}
#include <variant>
namespace std { // Variants
template <class... Types>
class variant {
template <class T, class... Args>
T& emplace(Args&&...);
constexpr bool valueless_by_exception() const noexcept;
constexpr size_t index() const noexcept;
};
template <class T> struct variant_size;
template <class T>
inline constexpr size_t variant_size_v = variant_size<T>::value;
template <size_t I, class T> struct variant_alternative<I, const T>;
template <size_t I, class T>
using variant_alternative_t = typename variant_alternative<I, T>::type;
inline constexpr size_t variant_npos = -1;
template <class T, class... Types>
constexpr bool holds_alternative(const variant<Types...>&) noexcept;
template <size_t I, class... Types>
constexpr variant_alternative_t<I, variant<Types...>>& get(variant<Types...>&);
template <class T, class... Types>
constexpr add_pointer_t<T> get_if(variant<Types...>*) noexcept;
template <class Visitor, class... Variants>
constexpr visit(Visitor&&, Variants&&...);
struct monostate;
class bad_variant_access : public exception {};
}
#include <any>
namespace std { // Storage for any type
class bad_any_cast : public bad_cast {};
class any {
template <class T, class... Args>
decay_t<T>& emplace(Args&& ...);
void reset() noexcept;
void swap(any& rhs) noexcept;
bool has_value() const noexcept;
const type_info& type() const noexcept;
};
template <class T, class... Args>
any make_any(Args&& ...args);
template <class T>
T any_cast(const any& operand);
}
#include <bitset>
namespace std { // Bitsets
template <size_t N> class bitset {
// bit reference:
class reference {
reference& flip() noexcept; // for b[i].flip();
};
bitset<N>& set() noexcept;
bitset<N>& set(size_t pos, bool val = true);
bitset<N>& reset() noexcept;
bitset<N>& reset(size_t pos);
bitset<N>& flip() noexcept;
bitset<N>& flip(size_t pos);
unsigned long to_ulong() const;
unsigned long long to_ullong() const;
basic_string to_string() const;
size_t count() const noexcept;
constexpr size_t size() const noexcept;
bool test(size_t pos) const;
bool all() const noexcept;
bool any() const noexcept;
bool none() const noexcept;
};
}
#include <memory>
namespace std { // Memory
template <class Ptr> struct pointer_traits {
using pointer = Ptr;
using element_type;
using difference_type;
template <class U> using rebind;
static pointer pointer_to(r);
};
template <class T> struct pointer_traits<T*>;
template <class Ptr> auto to_address(const Ptr& p) noexcept; // C++20
enum class pointer_safety { relaxed, preferred, strict };
// Pointer safety
void declare_reachable(void* p);
template <class T> T* undeclare_reachable(T* p);
void declare_no_pointers(char* p, size_t n);
void undeclare_no_pointers(char* p, size_t n);
pointer_safety get_pointer_safety() noexcept;
// Align
void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
template <size_t N, class T>
[[nodiscard]] constexpr T* assume_aligned(T* ptr); // C++20
// Allocator argument tag
struct allocator_arg_t { explicit allocator_arg_t() = default; };
inline constexpr allocator_arg_t allocator_arg{};
// uses_allocator
template <class T, class Alloc> struct uses_allocator;
template <class T, class Alloc>
inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
template <class T, class Alloc>
auto uses_allocator_construction_args(const Alloc& alloc); // C++20
template <class T, class Alloc, class... Args>
T make_obj_using_allocator(const Alloc& alloc, Args&&... args); // C++20
template <class T, class Alloc, class... Args>
T* uninitialized_construct_using_allocator(T* p, const Alloc& alloc, Args&&... args); // C++20
// Allocator traits
template <class Alloc> struct allocator_traits {
using allocator_type = Alloc;
using value_type = typename Alloc::value_type;
using pointer;
using const_pointer;
using void_pointer;
using const_void_pointer;
using propagate_on_container_copy_assignment;
using propagate_on_container_move_assignment;
using propagate_on_container_swap;
using is_always_equal;
template <class T> using rebind_alloc;
template <class T> using rebind_traits;
[[nodiscard]] static pointer allocate(Alloc& a, size_type n);
[[nodiscard]] static pointer allocate(Alloc& a, size_type n, const_void_pointer hint);
static void deallocate(Alloc& a, pointer p, size_type n);
template <class T, class... Args>
static void construct(Alloc& a, T* p, Args&&... args);
template <class T>
static void destroy(Alloc& a, T* p);
static size_type max_size(const Alloc& a) noexcept;
static Alloc select_on_container_copy_construction(const Alloc& rhs);
};
// The default allocator
template <class T> class allocator;
template <class T> constexpr T* addressof(T& r) noexcept;
// Specialized algorithms
template <class ForwardIterator>
void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n)
template <class ForwardIterator>
void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
template <class InputIterator, class Size, class ForwardIterator>
ForwardIterator uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
template <class InputIterator, class Size, class ForwardIterator>
pair<InputIterator, ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
template <class ForwardIterator, class T>
void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
template <class ForwardIterator, class Size, class T>
ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
template<class T, class... Args>
constexpr T* construct_at(T* location, Args&&... args);
template <class T>
void destroy_at(T* location);
template <class ForwardIterator>
void destroy(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator destroy_n(ForwardIterator first, Size n);
// unique_ptr
template <class T> struct default_delete;
template <class T> struct default_delete<T[]>;
template <class T, class D = default_delete<T>>
class unique_ptr {
using pointer;
using element_type = T;
using deleter_type = D;
pointer get() const noexcept;
deleter_type& get_deleter() noexcept
pointer release() noexcept;
void reset(pointer p = pointer()) noexcept;
void swap(unique_ptr& u) noexcept;
};
template <class T, class D> class unique_ptr<T[], D>;
template <class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
template <class T> unique_ptr<T> make_unique(size_t n);
template <class T> unique_ptr<T> make_unique_for_overwrite(size_t n); // C++20
template <class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
// Shared-ownership pointers
class bad_weak_ptr : public exception {};
template <class T>
class shared_ptr {
using element_type = remove_extent_t<T>;
using weak_type = weak_ptr<T>;
void swap(shared_ptr& r) noexcept;
void reset() noexcept;
element_type* get() const noexcept;
long use_count() const noexcept;
template <class U> bool owner_before(const shared_ptr<U>& b) const noexcept;
};
template <class T, class... Args>
shared_ptr<T> make_shared(Args&&... args);
template <class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
template<class T> shared_ptr<T> make_shared_for_overwrite(size_t N); // C++20
template<class T, class A> shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N); // C++20
template <class T, class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
template <class T, class U>
shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;
template <class T, class U>
shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;
template <class T, class U>
shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;
template <class D, class T>
D* get_deleter(const shared_ptr<T>& p) noexcept;
template <class T>
class weak_ptr {
using element_type = T;
long use_count() const noexcept;
bool expired() const noexcept;
shared_ptr<T> lock() const noexcept;
};
template <class T = void> struct owner_less;
template <> struct owner_less<void> {
using is_transparent;
};
template <class T> class enable_shared_from_this {
shared_ptr<T> shared_from_this();
shared_ptr<T const> shared_from_this() const;
weak_ptr<T> weak_from_this() noexcept;
weak_ptr<T const> weak_from_this() const noexcept;
};
template <class T>
bool atomic_is_lock_free(const shared_ptr<T>* p);
template <class Y> [[deprecated]] struct auto_ptr_ref {}; // C++03
template <class X> [[deprecated]] class auto_ptr {}; // C++03
}
#include <memory_resource>
namespace std::pmr { // Memory resources
class memory_resource {
static constexpr size_t max_align = alignof(max_align_t);
[[nodiscard]] void* allocate(size_t bytes, size_t alignment = max_align);
void deallocate(void* p, size_t bytes, size_t alignment = max_align);
bool is_equal(const memory_resource& other) const noexcept;
};
template <class Tp>
class polymorphic_allocator {
using value_type = Tp;
[[nodiscard]] Tp* allocate(size_t n);
void deallocate(Tp* p, size_t n);
void* allocate_bytes(size_t nbytes, size_t alignment = alignof(max_align_t));
void deallocate_bytes(void* p, size_t nbytes, size_t alignment = alignof(max_align_t));
template <class T> T* allocate_object(size_t n = 1);
template <class T> void deallocate_object(T* p, size_t n = 1);
template <class T, class... CtorArgs> T* new_object(CtorArgs&&... ctor_args);
template <class T> void delete_object(T* p);
template <class T, class... Args>
void construct(T* p, Args&&... args);
template <class T>
void destroy(T* p);
polymorphic_allocator select_on_container_copy_construction() const;
memory_resource* resource() const;
};
memory_resource* new_delete_resource() noexcept;
memory_resource* null_memory_resource() noexcept;
memory_resource* set_default_resource(memory_resource* r) noexcept;
memory_resource* get_default_resource() noexcept;
// Pool resource
struct pool_options {
size_t max_blocks_per_chunk = 0;
size_t largest_required_pool_block = 0;
};
class synchronized_pool_resource : public memory_resource {
void release();
memory_resource* upstream_resource() const;
pool_options options() const;
};
class unsynchronized_pool_resource : public memory_resource {};
class monotonic_buffer_resource : public memory_resource {};
}
#include <scoped_allocator>
namespace std {
template <class OuterAlloc, class... InnerAlloc>
class scoped_allocator_adaptor : public OuterAlloc {
using outer_allocator_type = OuterAlloc;
using inner_allocator_type;
using propagate_on_container_copy_assignment;
using propagate_on_container_move_assignment;
using propagate_on_container_swap;
using is_always_equal;
template <class Tp>
struct rebind {
using other = scoped_allocator_adaptor<OuterTraits::template rebind_alloc<Tp>, InnerAllocs...>;
};
inner_allocator_type& inner_allocator() noexcept;
const inner_allocator_type& inner_allocator() const noexcept;
outer_allocator_type& outer_allocator() noexcept;
const outer_allocator_type& outer_allocator() const noexcept;
scoped_allocator_adaptor select_on_container_copy_construction() const;
};
}
#include <functional>
namespace std { // Function objects
template <class F, class... Args>
invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) noexcept(is_nothrow_invocable_v<F, Args...>);
template <class T> class reference_wrapper {
using type = T;
T& get() const noexcept;
};
template <class T> reference_wrapper<T> ref(T&) noexcept;
template <class T> reference_wrapper<const T> cref(const T&) noexcept;
template <class T> void ref(const T&&) = delete;
template <class T> void cref(const T&&) = delete;
// arithmetic operations
template <class T = void> struct plus;
template <class T = void> struct minus;
template <class T = void> struct multiplies;
template <class T = void> struct divides;
template <class T = void> struct modulus;
template <class T = void> struct negate;
// comparisons
template <class T = void> struct equal_to;
template <class T = void> struct not_equal_to;
template <class T = void> struct greater;
template <class T = void> struct less;
template <class T = void> struct greater_equal;
template <class T = void> struct less_equal;
// logical operations
template <class T = void> struct logical_and;
template <class T = void> struct logical_or;
template <class T = void> struct logical_not;
// bitwise operations
template <class T = void> struct bit_and;
template <class T = void> struct bit_or;
template <class T = void> struct bit_xor;
template <class T = void> struct bit_not;
struct identity { // // C++20
using is_transparent
};
template <class F>
not_fn(F&& f);
template <class F, class... Args> bind_front(F&&, Args&&...); // C++20
template <class T> struct is_bind_expression;
template <class T> struct is_placeholder;
template <class F, class... BoundArgs>
bind(F&&, BoundArgs&&...);
template <class R, class T>
mem_fn(R T::*) noexcept;
class bad_function_call : public exception {};
template <class R, class... ArgTypes>
class function<R(ArgTypes...)> {
using result_type = R;
const type_info& target_type() const noexcept;
template <class T> T* target() noexcept;
template <class T> const T* target() const noexcept;
};
template <class ForwardIterator, class BinaryPredicate = equal_to<>> class default_searcher;
template <class RandomAccessIterator, class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>>, class boyer_moore_searcher;
template <class RandomAccessIterator, class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>, class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher;
template <class T> inline constexpr bool is_bind_expression_v = is_bind_expression<T>::value;
template <class T> inline constexpr int is_placeholder_v = is_placeholder<T>::value;
namespace ranges { // C++20
// concept-constrained comparisons
struct equal_to;
struct not_equal_to;