aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-13 20:39:49 +0000
commitfe6060f10f634930ff71b7c50291ddc610da2475 (patch)
tree1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/libcxx/include
parentb61bce17f346d79cecfd8f195a64b10f77be43b1 (diff)
parent344a3780b2e33f6ca763666c380202b18aab72a3 (diff)
downloadsrc-fe6060f10f634930ff71b7c50291ddc610da2475.tar.gz
src-fe6060f10f634930ff71b7c50291ddc610da2475.zip
Merge llvm-project main llvmorg-13-init-16847-g88e66fa60ae5
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-13-init-16847-g88e66fa60ae5, the last commit before the upstream release/13.x branch was created. PR: 258209 MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/libcxx/include')
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h51
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/all_of.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/any_of.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/binary_search.h61
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/clamp.h52
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/comp.h97
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h87
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy.h82
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h84
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy_if.h48
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy_n.h72
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/count.h40
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/count_if.h40
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/equal.h90
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/equal_range.h87
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/fill.h55
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/fill_n.h47
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_end.h154
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h57
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_if.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/for_each.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h47
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/generate.h36
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/generate_n.h40
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/half_positive.h54
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/includes.h67
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h231
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_heap.h48
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h65
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_partitioned.h43
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h168
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h48
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h55
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h68
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/lower_bound.h72
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/make_heap.h64
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/max.h70
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/max_element.h58
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/merge.h76
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/min.h70
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/min_element.h57
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/minmax.h101
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/minmax_element.h90
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/mismatch.h72
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/move.h83
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/move_backward.h84
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/none_of.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/nth_element.h244
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h71
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partition.h88
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partition_copy.h52
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partition_point.h51
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h62
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/push_heap.h75
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove.h50
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h43
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h43
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove_if.h51
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h41
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h41
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace_if.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/reverse.h61
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/rotate.h205
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h38
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sample.h101
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/search.h131
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/search_n.h116
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/set_difference.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/set_intersection.h74
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/set_symmetric_difference.h82
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/set_union.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/shift_left.h61
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/shift_right.h106
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/shuffle.h127
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sift_down.h84
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sort.h530
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h58
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h305
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h235
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/transform.h48
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unique.h63
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h114
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h87
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/upper_bound.h72
-rw-r--r--contrib/llvm-project/libcxx/include/__availability35
-rw-r--r--contrib/llvm-project/libcxx/include/__bit_reference2
-rw-r--r--contrib/llvm-project/libcxx/include/__bits3
-rw-r--r--contrib/llvm-project/libcxx/include/__bsd_locale_fallbacks.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__config265
-rw-r--r--contrib/llvm-project/libcxx/include/__debug2
-rw-r--r--contrib/llvm-project/libcxx/include/__errc2
-rw-r--r--contrib/llvm-project/libcxx/include/__format/format_error.h56
-rw-r--r--contrib/llvm-project/libcxx/include/__format/format_parse_context.h113
-rw-r--r--contrib/llvm-project/libcxx/include/__function_like.h56
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/binary_function.h31
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/binary_negate.h50
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/bind.h386
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/bind_front.h52
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/binder1st.h54
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/binder2nd.h54
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/default_searcher.h56
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/function.h (renamed from contrib/llvm-project/libcxx/include/__functional_03)1276
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/hash.h873
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/identity.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/invoke.h100
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/is_transparent.h36
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/mem_fn.h161
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/mem_fun_ref.h173
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/not_fn.h47
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/operations.h729
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/perfect_forward.h88
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/pointer_to_binary_function.h46
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/pointer_to_unary_function.h46
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/ranges_operations.h97
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/reference_wrapper.h223
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/unary_function.h34
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/unary_negate.h47
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/unwrap_ref.h62
-rw-r--r--contrib/llvm-project/libcxx/include/__functional/weak_result_type.h481
-rw-r--r--contrib/llvm-project/libcxx/include/__functional_base645
-rw-r--r--contrib/llvm-project/libcxx/include/__functional_base_03223
-rw-r--r--contrib/llvm-project/libcxx/include/__hash_table66
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/access.h134
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/advance.h200
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/back_insert_iterator.h75
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/common_iterator.h301
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/concepts.h272
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h306
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/data.h56
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h35
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/distance.h56
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/empty.h49
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/erase_if_container.h45
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/front_insert_iterator.h75
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h77
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/istream_iterator.h103
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/istreambuf_iterator.h110
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/iter_move.h91
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/iter_swap.h107
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/iterator.h40
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h500
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/move_iterator.h189
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/next.h87
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/ostream_iterator.h75
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/ostreambuf_iterator.h81
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/prev.h79
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/projected.h45
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/readable_traits.h91
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/reverse_access.h109
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h239
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/size.h58
-rw-r--r--contrib/llvm-project/libcxx/include/__iterator/wrap_iter.h300
-rw-r--r--contrib/llvm-project/libcxx/include/__libcpp_version2
-rw-r--r--contrib/llvm-project/libcxx/include/__locale26
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/addressof.h (renamed from contrib/llvm-project/libcxx/include/__memory/base.h)37
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/allocation_guard.h (renamed from contrib/llvm-project/libcxx/include/__memory/utilities.h)7
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/allocator.h254
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/allocator_arg_t.h78
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/allocator_traits.h12
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/auto_ptr.h86
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/compressed_pair.h201
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/construct_at.h59
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/pointer_safety.h57
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/pointer_traits.h51
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/raw_storage_iterator.h73
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/shared_ptr.h1879
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h89
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h261
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/unique_ptr.h773
-rw-r--r--contrib/llvm-project/libcxx/include/__memory/uses_allocator.h60
-rw-r--r--contrib/llvm-project/libcxx/include/__mutex_base8
-rw-r--r--contrib/llvm-project/libcxx/include/__node_handle3
-rw-r--r--contrib/llvm-project/libcxx/include/__nullptr4
-rw-r--r--contrib/llvm-project/libcxx/include/__random/uniform_int_distribution.h316
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/access.h222
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/all.h86
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/common_view.h113
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/concepts.h138
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/copyable_box.h175
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/dangling.h47
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/data.h86
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/drop_view.h131
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/empty.h86
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/empty_view.h46
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h46
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/enable_view.h42
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h99
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/ref_view.h87
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/size.h132
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/subrange.h267
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/transform_view.h408
-rw-r--r--contrib/llvm-project/libcxx/include/__ranges/view_interface.h198
-rw-r--r--contrib/llvm-project/libcxx/include/__split_buffer13
-rw-r--r--contrib/llvm-project/libcxx/include/__sso_allocator77
-rw-r--r--contrib/llvm-project/libcxx/include/__std_stream6
-rw-r--r--contrib/llvm-project/libcxx/include/__string72
-rw-r--r--contrib/llvm-project/libcxx/include/__threading_support23
-rw-r--r--contrib/llvm-project/libcxx/include/__tree12
-rw-r--r--contrib/llvm-project/libcxx/include/__tuple4
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/__decay_copy.h39
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/as_const.h38
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/cmp.h107
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/declval.h39
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/exchange.h40
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/forward.h42
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/in_place.h63
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/integer_sequence.h83
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/move.h52
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/pair.h585
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/piecewise_construct.h34
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/rel_ops.h67
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/swap.h55
-rw-r--r--contrib/llvm-project/libcxx/include/__utility/to_underlying.h45
-rw-r--r--contrib/llvm-project/libcxx/include/__variant/monostate.h65
-rw-r--r--contrib/llvm-project/libcxx/include/algorithm5328
-rw-r--r--contrib/llvm-project/libcxx/include/any7
-rw-r--r--contrib/llvm-project/libcxx/include/array15
-rw-r--r--contrib/llvm-project/libcxx/include/atomic77
-rw-r--r--contrib/llvm-project/libcxx/include/barrier9
-rw-r--r--contrib/llvm-project/libcxx/include/bit82
-rw-r--r--contrib/llvm-project/libcxx/include/bitset24
-rw-r--r--contrib/llvm-project/libcxx/include/ccomplex2
-rw-r--r--contrib/llvm-project/libcxx/include/cctype30
-rw-r--r--contrib/llvm-project/libcxx/include/cerrno2
-rw-r--r--contrib/llvm-project/libcxx/include/cfenv30
-rw-r--r--contrib/llvm-project/libcxx/include/cfloat2
-rw-r--r--contrib/llvm-project/libcxx/include/charconv137
-rw-r--r--contrib/llvm-project/libcxx/include/chrono33
-rw-r--r--contrib/llvm-project/libcxx/include/cinttypes16
-rw-r--r--contrib/llvm-project/libcxx/include/ciso6462
-rw-r--r--contrib/llvm-project/libcxx/include/climits2
-rw-r--r--contrib/llvm-project/libcxx/include/clocale8
-rw-r--r--contrib/llvm-project/libcxx/include/cmath428
-rw-r--r--contrib/llvm-project/libcxx/include/codecvt2
-rw-r--r--contrib/llvm-project/libcxx/include/compare570
-rw-r--r--contrib/llvm-project/libcxx/include/complex6
-rw-r--r--contrib/llvm-project/libcxx/include/complex.h4
-rw-r--r--contrib/llvm-project/libcxx/include/concepts304
-rw-r--r--contrib/llvm-project/libcxx/include/condition_variable2
-rw-r--r--contrib/llvm-project/libcxx/include/csetjmp6
-rw-r--r--contrib/llvm-project/libcxx/include/csignal8
-rw-r--r--contrib/llvm-project/libcxx/include/cstdarg4
-rw-r--r--contrib/llvm-project/libcxx/include/cstdbool2
-rw-r--r--contrib/llvm-project/libcxx/include/cstddef14
-rw-r--r--contrib/llvm-project/libcxx/include/cstdint72
-rw-r--r--contrib/llvm-project/libcxx/include/cstdio102
-rw-r--r--contrib/llvm-project/libcxx/include/cstdlib88
-rw-r--r--contrib/llvm-project/libcxx/include/cstring48
-rw-r--r--contrib/llvm-project/libcxx/include/ctgmath2
-rw-r--r--contrib/llvm-project/libcxx/include/ctime32
-rw-r--r--contrib/llvm-project/libcxx/include/ctype.h2
-rw-r--r--contrib/llvm-project/libcxx/include/cwchar130
-rw-r--r--contrib/llvm-project/libcxx/include/cwctype44
-rw-r--r--contrib/llvm-project/libcxx/include/deque50
-rw-r--r--contrib/llvm-project/libcxx/include/errno.h2
-rw-r--r--contrib/llvm-project/libcxx/include/exception18
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/__config4
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/__memory27
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/functional45
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/iterator3
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/propagate_const2
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/simd4
-rw-r--r--contrib/llvm-project/libcxx/include/experimental/type_traits2
-rw-r--r--contrib/llvm-project/libcxx/include/ext/__hash3
-rw-r--r--contrib/llvm-project/libcxx/include/ext/hash_map6
-rw-r--r--contrib/llvm-project/libcxx/include/ext/hash_set4
-rw-r--r--contrib/llvm-project/libcxx/include/filesystem142
-rw-r--r--contrib/llvm-project/libcxx/include/float.h2
-rw-r--r--contrib/llvm-project/libcxx/include/format84
-rw-r--r--contrib/llvm-project/libcxx/include/forward_list61
-rw-r--r--contrib/llvm-project/libcxx/include/fstream45
-rw-r--r--contrib/llvm-project/libcxx/include/functional2786
-rw-r--r--contrib/llvm-project/libcxx/include/future55
-rw-r--r--contrib/llvm-project/libcxx/include/initializer_list4
-rw-r--r--contrib/llvm-project/libcxx/include/inttypes.h2
-rw-r--r--contrib/llvm-project/libcxx/include/iomanip20
-rw-r--r--contrib/llvm-project/libcxx/include/ios25
-rw-r--r--contrib/llvm-project/libcxx/include/iosfwd15
-rw-r--r--contrib/llvm-project/libcxx/include/iostream6
-rw-r--r--contrib/llvm-project/libcxx/include/istream97
-rw-r--r--contrib/llvm-project/libcxx/include/iterator1910
-rw-r--r--contrib/llvm-project/libcxx/include/latch2
-rw-r--r--contrib/llvm-project/libcxx/include/limits2
-rw-r--r--contrib/llvm-project/libcxx/include/limits.h2
-rw-r--r--contrib/llvm-project/libcxx/include/list92
-rw-r--r--contrib/llvm-project/libcxx/include/locale79
-rw-r--r--contrib/llvm-project/libcxx/include/locale.h2
-rw-r--r--contrib/llvm-project/libcxx/include/map86
-rw-r--r--contrib/llvm-project/libcxx/include/math.h320
-rw-r--r--contrib/llvm-project/libcxx/include/memory3447
-rw-r--r--contrib/llvm-project/libcxx/include/module.modulemap293
-rw-r--r--contrib/llvm-project/libcxx/include/mutex17
-rw-r--r--contrib/llvm-project/libcxx/include/new6
-rw-r--r--contrib/llvm-project/libcxx/include/numbers37
-rw-r--r--contrib/llvm-project/libcxx/include/numeric11
-rw-r--r--contrib/llvm-project/libcxx/include/optional193
-rw-r--r--contrib/llvm-project/libcxx/include/ostream121
-rw-r--r--contrib/llvm-project/libcxx/include/queue124
-rw-r--r--contrib/llvm-project/libcxx/include/random102
-rw-r--r--contrib/llvm-project/libcxx/include/ranges207
-rw-r--r--contrib/llvm-project/libcxx/include/ratio12
-rw-r--r--contrib/llvm-project/libcxx/include/regex36
-rw-r--r--contrib/llvm-project/libcxx/include/scoped_allocator7
-rw-r--r--contrib/llvm-project/libcxx/include/semaphore6
-rw-r--r--contrib/llvm-project/libcxx/include/set98
-rw-r--r--contrib/llvm-project/libcxx/include/setjmp.h2
-rw-r--r--contrib/llvm-project/libcxx/include/shared_mutex8
-rw-r--r--contrib/llvm-project/libcxx/include/span33
-rw-r--r--contrib/llvm-project/libcxx/include/sstream50
-rw-r--r--contrib/llvm-project/libcxx/include/stack36
-rw-r--r--contrib/llvm-project/libcxx/include/stdbool.h2
-rw-r--r--contrib/llvm-project/libcxx/include/stddef.h2
-rw-r--r--contrib/llvm-project/libcxx/include/stdexcept4
-rw-r--r--contrib/llvm-project/libcxx/include/stdint.h2
-rw-r--r--contrib/llvm-project/libcxx/include/stdio.h2
-rw-r--r--contrib/llvm-project/libcxx/include/stdlib.h16
-rw-r--r--contrib/llvm-project/libcxx/include/streambuf8
-rw-r--r--contrib/llvm-project/libcxx/include/string355
-rw-r--r--contrib/llvm-project/libcxx/include/string.h2
-rw-r--r--contrib/llvm-project/libcxx/include/string_view86
-rw-r--r--contrib/llvm-project/libcxx/include/strstream14
-rw-r--r--contrib/llvm-project/libcxx/include/system_error15
-rw-r--r--contrib/llvm-project/libcxx/include/tgmath.h4
-rw-r--r--contrib/llvm-project/libcxx/include/thread31
-rw-r--r--contrib/llvm-project/libcxx/include/tuple1081
-rw-r--r--contrib/llvm-project/libcxx/include/type_traits548
-rw-r--r--contrib/llvm-project/libcxx/include/typeindex6
-rw-r--r--contrib/llvm-project/libcxx/include/typeinfo54
-rw-r--r--contrib/llvm-project/libcxx/include/unordered_map51
-rw-r--r--contrib/llvm-project/libcxx/include/unordered_set45
-rw-r--r--contrib/llvm-project/libcxx/include/utility1469
-rw-r--r--contrib/llvm-project/libcxx/include/valarray231
-rw-r--r--contrib/llvm-project/libcxx/include/variant140
-rw-r--r--contrib/llvm-project/libcxx/include/vector104
-rw-r--r--contrib/llvm-project/libcxx/include/version42
-rw-r--r--contrib/llvm-project/libcxx/include/wchar.h4
-rw-r--r--contrib/llvm-project/libcxx/include/wctype.h4
347 files changed, 30468 insertions, 18974 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h b/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h
new file mode 100644
index 000000000000..0a2aa055c100
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/adjacent_find.h
@@ -0,0 +1,51 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H
+#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
+ if (__first != __last) {
+ _ForwardIterator __i = __first;
+ while (++__i != __last) {
+ if (__pred(*__first, *__i))
+ return __first;
+ __first = __i;
+ }
+ }
+ return __last;
+}
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
+ typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+ return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/all_of.h b/contrib/llvm-project/libcxx/include/__algorithm/all_of.h
new file mode 100644
index 000000000000..7d6ed5085963
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/all_of.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ALL_OF_H
+#define _LIBCPP___ALGORITHM_ALL_OF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
+ for (; __first != __last; ++__first)
+ if (!__pred(*__first))
+ return false;
+ return true;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ALL_OF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/any_of.h b/contrib/llvm-project/libcxx/include/__algorithm/any_of.h
new file mode 100644
index 000000000000..d5a6c094a673
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/any_of.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ANY_OF_H
+#define _LIBCPP___ALGORITHM_ANY_OF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ return true;
+ return false;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ANY_OF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h b/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h
new file mode 100644
index 000000000000..766f5da16296
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_BINARY_SEARCH_H
+#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
+ return __first != __last && !__comp(__value_, *__first);
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);
+}
+
+template <class _ForwardIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+ return _VSTD::binary_search(__first, __last, __value_,
+ __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+}
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/clamp.h b/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
new file mode 100644
index 000000000000..f8eba03cf890
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_CLAMP_H
+#define _LIBCPP___ALGORITHM_CLAMP_H
+
+#include <__config>
+#include <__debug>
+#include <__algorithm/comp.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+// clamp
+template<class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+const _Tp&
+clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
+{
+ _LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
+ return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
+
+}
+
+template<class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+const _Tp&
+clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
+{
+ return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_CLAMP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/comp.h b/contrib/llvm-project/libcxx/include/__algorithm/comp.h
new file mode 100644
index 000000000000..2039cf7b3955
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/comp.h
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COMP_H
+#define _LIBCPP___ALGORITHM_COMP_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
+// * That only works with C++14 and later, and
+// * We haven't included <functional> here.
+template <class _T1, class _T2 = _T1>
+struct __equal_to
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
+};
+
+template <class _T1>
+struct __equal_to<_T1, _T1>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+};
+
+template <class _T1>
+struct __equal_to<const _T1, _T1>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+};
+
+template <class _T1>
+struct __equal_to<_T1, const _T1>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+};
+
+template <class _T1, class _T2 = _T1>
+struct __less
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
+};
+
+template <class _T1>
+struct __less<_T1, _T1>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+};
+
+template <class _T1>
+struct __less<const _T1, _T1>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+};
+
+template <class _T1>
+struct __less<_T1, const _T1>
+{
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COMP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h b/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h
new file mode 100644
index 000000000000..b3bca82c0953
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
+#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_DEBUG
+
+template <class _Compare>
+struct __debug_less
+{
+ _Compare &__comp_;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __debug_less(_Compare& __c) : __comp_(__c) {}
+
+ template <class _Tp, class _Up>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ bool operator()(const _Tp& __x, const _Up& __y)
+ {
+ bool __r = __comp_(__x, __y);
+ if (__r)
+ __do_compare_assert(0, __y, __x);
+ return __r;
+ }
+
+ template <class _Tp, class _Up>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ bool operator()(_Tp& __x, _Up& __y)
+ {
+ bool __r = __comp_(__x, __y);
+ if (__r)
+ __do_compare_assert(0, __y, __x);
+ return __r;
+ }
+
+ template <class _LHS, class _RHS>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_INLINE_VISIBILITY
+ decltype((void)declval<_Compare&>()(
+ declval<_LHS &>(), declval<_RHS &>()))
+ __do_compare_assert(int, _LHS & __l, _RHS & __r) {
+ _LIBCPP_ASSERT(!__comp_(__l, __r),
+ "Comparator does not induce a strict weak ordering");
+ }
+
+ template <class _LHS, class _RHS>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ inline _LIBCPP_INLINE_VISIBILITY
+ void __do_compare_assert(long, _LHS &, _RHS &) {}
+};
+
+#endif // _LIBCPP_DEBUG
+
+template <class _Comp>
+struct __comp_ref_type {
+ // Pass the comparator by lvalue reference. Or in debug mode, using a
+ // debugging wrapper that stores a reference.
+#ifndef _LIBCPP_DEBUG
+ typedef typename add_lvalue_reference<_Comp>::type type;
+#else
+ typedef __debug_less<_Comp> type;
+#endif
+};
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy.h b/contrib/llvm-project/libcxx/include/__algorithm/copy.h
new file mode 100644
index 000000000000..9db7434c043d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy.h
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COPY_H
+#define _LIBCPP___ALGORITHM_COPY_H
+
+#include <__config>
+#include <__algorithm/unwrap_iter.h>
+#include <__iterator/iterator_traits.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// copy
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ for (; __first != __last; ++__first, (void) ++__result)
+ *__result = *__first;
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ return _VSTD::__copy_constexpr(__first, __last, __result);
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_same<typename remove_const<_Tp>::type, _Up>::value &&
+ is_trivially_copy_assignable<_Up>::value,
+ _Up*
+>::type
+__copy(_Tp* __first, _Tp* __last, _Up* __result)
+{
+ const size_t __n = static_cast<size_t>(__last - __first);
+ if (__n > 0)
+ _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+ return __result + __n;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ if (__libcpp_is_constant_evaluated()) {
+ return _VSTD::__copy_constexpr(__first, __last, __result);
+ } else {
+ return _VSTD::__rewrap_iter(__result,
+ _VSTD::__copy(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result)));
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h
new file mode 100644
index 000000000000..03a9c5f2d001
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_backward.h
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
+#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
+
+#include <__config>
+#include <__algorithm/unwrap_iter.h>
+#include <__iterator/iterator_traits.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BidirectionalIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+{
+ while (__first != __last)
+ *--__result = *--__last;
+ return __result;
+}
+
+template <class _BidirectionalIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+{
+ return _VSTD::__copy_backward_constexpr(__first, __last, __result);
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ is_same<typename remove_const<_Tp>::type, _Up>::value &&
+ is_trivially_copy_assignable<_Up>::value,
+ _Up*
+>::type
+__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
+{
+ const size_t __n = static_cast<size_t>(__last - __first);
+ if (__n > 0)
+ {
+ __result -= __n;
+ _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+ }
+ return __result;
+}
+
+template <class _BidirectionalIterator1, class _BidirectionalIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_BidirectionalIterator2
+copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+ _BidirectionalIterator2 __result)
+{
+ if (__libcpp_is_constant_evaluated()) {
+ return _VSTD::__copy_backward_constexpr(__first, __last, __result);
+ } else {
+ return _VSTD::__rewrap_iter(__result,
+ _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result)));
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h
new file mode 100644
index 000000000000..153304c7a765
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COPY_IF_H
+#define _LIBCPP___ALGORITHM_COPY_IF_H
+
+#include <__config>
+#include <__algorithm/unwrap_iter.h>
+#include <__iterator/iterator_traits.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _InputIterator, class _OutputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+copy_if(_InputIterator __first, _InputIterator __last,
+ _OutputIterator __result, _Predicate __pred)
+{
+ for (; __first != __last; ++__first)
+ {
+ if (__pred(*__first))
+ {
+ *__result = *__first;
+ ++__result;
+ }
+ }
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COPY_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h
new file mode 100644
index 000000000000..bbfeb8686fbf
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COPY_N_H
+#define _LIBCPP___ALGORITHM_COPY_N_H
+
+#include <__config>
+#include <__algorithm/copy.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__iterator/iterator_traits.h>
+#include <cstring>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _InputIterator, class _Size, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+typename enable_if
+<
+ __is_cpp17_input_iterator<_InputIterator>::value &&
+ !__is_cpp17_random_access_iterator<_InputIterator>::value,
+ _OutputIterator
+>::type
+copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
+{
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
+ if (__n > 0)
+ {
+ *__result = *__first;
+ ++__result;
+ for (--__n; __n > 0; --__n)
+ {
+ ++__first;
+ *__result = *__first;
+ ++__result;
+ }
+ }
+ return __result;
+}
+
+template<class _InputIterator, class _Size, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+typename enable_if
+<
+ __is_cpp17_random_access_iterator<_InputIterator>::value,
+ _OutputIterator
+>::type
+copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
+{
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
+ return _VSTD::copy(__first, __first + __n, __result);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COPY_N_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/count.h b/contrib/llvm-project/libcxx/include/__algorithm/count.h
new file mode 100644
index 000000000000..7f2d1954cd6b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/count.h
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COUNT_H
+#define _LIBCPP___ALGORITHM_COUNT_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename iterator_traits<_InputIterator>::difference_type
+ count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
+ typename iterator_traits<_InputIterator>::difference_type __r(0);
+ for (; __first != __last; ++__first)
+ if (*__first == __value_)
+ ++__r;
+ return __r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COUNT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/count_if.h b/contrib/llvm-project/libcxx/include/__algorithm/count_if.h
new file mode 100644
index 000000000000..a5efffb92603
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/count_if.h
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_COUNT_IF_H
+#define _LIBCPP___ALGORITHM_COUNT_IF_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename iterator_traits<_InputIterator>::difference_type
+ count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
+ typename iterator_traits<_InputIterator>::difference_type __r(0);
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ ++__r;
+ return __r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_COUNT_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/equal.h b/contrib/llvm-project/libcxx/include/__algorithm/equal.h
new file mode 100644
index 000000000000..bc6755981963
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/equal.h
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_EQUAL_H
+#define _LIBCPP___ALGORITHM_EQUAL_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+#include <iterator> // FIXME: replace with <__iterator/distance.h> when it lands
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
+ for (; __first1 != __last1; ++__first1, (void)++__first2)
+ if (!__pred(*__first1, *__first2))
+ return false;
+ return true;
+}
+
+template <class _InputIterator1, class _InputIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
+ typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+ typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+ return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+ _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) {
+ for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
+ if (!__pred(*__first1, *__first2))
+ return false;
+ return __first1 == __last1 && __first2 == __last2;
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
+ _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
+ random_access_iterator_tag) {
+ if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
+ return false;
+ return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2,
+ typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, __pred);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+ _BinaryPredicate __pred) {
+ return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>(
+ __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(),
+ typename iterator_traits<_InputIterator2>::iterator_category());
+}
+
+template <class _InputIterator1, class _InputIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
+ typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+ typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+ return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
+ typename iterator_traits<_InputIterator1>::iterator_category(),
+ typename iterator_traits<_InputIterator2>::iterator_category());
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_EQUAL_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h b/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h
new file mode 100644
index 000000000000..9694dae95003
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/equal_range.h
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_EQUAL_RANGE_H
+#define _LIBCPP___ALGORITHM_EQUAL_RANGE_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/half_positive.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/upper_bound.h>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
+__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+ difference_type __len = _VSTD::distance(__first, __last);
+ while (__len != 0)
+ {
+ difference_type __l2 = _VSTD::__half_positive(__len);
+ _ForwardIterator __m = __first;
+ _VSTD::advance(__m, __l2);
+ if (__comp(*__m, __value_))
+ {
+ __first = ++__m;
+ __len -= __l2 + 1;
+ }
+ else if (__comp(__value_, *__m))
+ {
+ __last = __m;
+ __len = __l2;
+ }
+ else
+ {
+ _ForwardIterator __mp1 = __m;
+ return pair<_ForwardIterator, _ForwardIterator>
+ (
+ _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
+ _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
+ );
+ }
+ }
+ return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_ForwardIterator, _ForwardIterator>
+equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
+}
+
+template <class _ForwardIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+pair<_ForwardIterator, _ForwardIterator>
+equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+ return _VSTD::equal_range(__first, __last, __value_,
+ __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/fill.h b/contrib/llvm-project/libcxx/include/__algorithm/fill.h
new file mode 100644
index 000000000000..4fefe86536d3
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/fill.h
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FILL_H
+#define _LIBCPP___ALGORITHM_FILL_H
+
+#include <__config>
+#include <__algorithm/fill_n.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
+{
+ for (; __first != __last; ++__first)
+ *__first = __value_;
+}
+
+template <class _RandomAccessIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
+{
+ _VSTD::fill_n(__first, __last - __first, __value_);
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+ _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FILL_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h b/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
new file mode 100644
index 000000000000..34a245edb51c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FILL_N_H
+#define _LIBCPP___ALGORITHM_FILL_N_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _OutputIterator, class _Size, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
+{
+ for (; __n > 0; ++__first, (void) --__n)
+ *__first = __value_;
+ return __first;
+}
+
+template <class _OutputIterator, class _Size, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
+{
+ return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FILL_N_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find.h b/contrib/llvm-project/libcxx/include/__algorithm/find.h
new file mode 100644
index 000000000000..bc593dc54254
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FIND_H
+#define _LIBCPP___ALGORITHM_FIND_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
+find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) {
+ for (; __first != __last; ++__first)
+ if (*__first == __value_)
+ break;
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FIND_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_end.h b/contrib/llvm-project/libcxx/include/__algorithm/find_end.h
new file mode 100644
index 000000000000..f4277f003aa8
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_end.h
@@ -0,0 +1,154 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FIND_END_OF_H
+#define _LIBCPP___ALGORITHM_FIND_END_OF_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate __pred, forward_iterator_tag,
+ forward_iterator_tag) {
+ // modeled after search algorithm
+ _ForwardIterator1 __r = __last1; // __last1 is the "default" answer
+ if (__first2 == __last2)
+ return __r;
+ while (true) {
+ while (true) {
+ if (__first1 == __last1) // if source exhausted return last correct answer
+ return __r; // (or __last1 if never found)
+ if (__pred(*__first1, *__first2))
+ break;
+ ++__first1;
+ }
+ // *__first1 matches *__first2, now match elements after here
+ _ForwardIterator1 __m1 = __first1;
+ _ForwardIterator2 __m2 = __first2;
+ while (true) {
+ if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one
+ __r = __first1;
+ ++__first1;
+ break;
+ }
+ if (++__m1 == __last1) // Source exhausted, return last answer
+ return __r;
+ if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first
+ {
+ ++__first1;
+ break;
+ } // else there is a match, check next elements
+ }
+ }
+}
+
+template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end(
+ _BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2,
+ _BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) {
+ // modeled after search algorithm (in reverse)
+ if (__first2 == __last2)
+ return __last1; // Everything matches an empty sequence
+ _BidirectionalIterator1 __l1 = __last1;
+ _BidirectionalIterator2 __l2 = __last2;
+ --__l2;
+ while (true) {
+ // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
+ while (true) {
+ if (__first1 == __l1) // return __last1 if no element matches *__first2
+ return __last1;
+ if (__pred(*--__l1, *__l2))
+ break;
+ }
+ // *__l1 matches *__l2, now match elements before here
+ _BidirectionalIterator1 __m1 = __l1;
+ _BidirectionalIterator2 __m2 = __l2;
+ while (true) {
+ if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
+ return __m1;
+ if (__m1 == __first1) // Otherwise if source exhaused, pattern not found
+ return __last1;
+ if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1
+ {
+ break;
+ } // else there is a match, check next elements
+ }
+ }
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(
+ _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
+ _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) {
+ // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
+ typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2;
+ if (__len2 == 0)
+ return __last1;
+ typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1;
+ if (__len1 < __len2)
+ return __last1;
+ const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here
+ _RandomAccessIterator1 __l1 = __last1;
+ _RandomAccessIterator2 __l2 = __last2;
+ --__l2;
+ while (true) {
+ while (true) {
+ if (__s == __l1)
+ return __last1;
+ if (__pred(*--__l1, *__l2))
+ break;
+ }
+ _RandomAccessIterator1 __m1 = __l1;
+ _RandomAccessIterator2 __m2 = __l2;
+ while (true) {
+ if (__m2 == __first2)
+ return __m1;
+ // no need to check range on __m1 because __s guarantees we have enough source
+ if (!__pred(*--__m1, *--__m2)) {
+ break;
+ }
+ }
+ }
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
+find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate __pred) {
+ return _VSTD::__find_end<typename add_lvalue_reference<_BinaryPredicate>::type>(
+ __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category());
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
+find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
+ typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+ typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+ return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FIND_END_OF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h b/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
new file mode 100644
index 000000000000..d956c8dda2f2
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
+#define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ for (; __first1 != __last1; ++__first1)
+ for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
+ if (__pred(*__first1, *__j))
+ return __first1;
+ return __last1;
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
+find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_first_of(
+ _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
+ typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+ typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+ return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_if.h b/contrib/llvm-project/libcxx/include/__algorithm/find_if.h
new file mode 100644
index 000000000000..456cc5b0a34e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_if.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FIND_IF_H
+#define _LIBCPP___ALGORITHM_FIND_IF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
+find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ break;
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FIND_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h b/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h
new file mode 100644
index 000000000000..d7d25160cc7d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FIND_IF_NOT_H
+#define _LIBCPP___ALGORITHM_FIND_IF_NOT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
+find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
+ for (; __first != __last; ++__first)
+ if (!__pred(*__first))
+ break;
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/for_each.h b/contrib/llvm-project/libcxx/include/__algorithm/for_each.h
new file mode 100644
index 000000000000..e71a36a1de40
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/for_each.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FOR_EACH_H
+#define _LIBCPP___ALGORITHM_FOR_EACH_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Function>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_each(_InputIterator __first,
+ _InputIterator __last,
+ _Function __f) {
+ for (; __first != __last; ++__first)
+ __f(*__first);
+ return __f;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FOR_EACH_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h b/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h
new file mode 100644
index 000000000000..77f6c862145f
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H
+#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _InputIterator, class _Size, class _Function>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator for_each_n(_InputIterator __first,
+ _Size __orig_n,
+ _Function __f) {
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
+ while (__n > 0) {
+ __f(*__first);
+ ++__first;
+ --__n;
+ }
+ return __first;
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/generate.h b/contrib/llvm-project/libcxx/include/__algorithm/generate.h
new file mode 100644
index 000000000000..d3e1133e2bc1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/generate.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_GENERATE_H
+#define _LIBCPP___ALGORITHM_GENERATE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Generator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
+{
+ for (; __first != __last; ++__first)
+ *__first = __gen();
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_GENERATE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h b/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h
new file mode 100644
index 000000000000..c31259858613
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_GENERATE_N_H
+#define _LIBCPP___ALGORITHM_GENERATE_N_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _OutputIterator, class _Size, class _Generator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
+{
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
+ for (; __n > 0; ++__first, (void) --__n)
+ *__first = __gen();
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_GENERATE_N_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h b/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h
new file mode 100644
index 000000000000..b03efc495b1a
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_HALF_POSITIVE_H
+#define _LIBCPP___ALGORITHM_HALF_POSITIVE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Perform division by two quickly for positive integers (llvm.org/PR39129)
+
+template <typename _Integral>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ is_integral<_Integral>::value,
+ _Integral
+>::type
+__half_positive(_Integral __value)
+{
+ return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename enable_if
+<
+ !is_integral<_Tp>::value,
+ _Tp
+>::type
+__half_positive(_Tp __value)
+{
+ return __value / 2;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/includes.h b/contrib/llvm-project/libcxx/include/__algorithm/includes.h
new file mode 100644
index 000000000000..ff298a51118e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/includes.h
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_INCLUDES_H
+#define _LIBCPP___ALGORITHM_INCLUDES_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+ _Compare __comp)
+{
+ for (; __first2 != __last2; ++__first1)
+ {
+ if (__first1 == __last1 || __comp(*__first2, *__first1))
+ return false;
+ if (!__comp(*__first1, *__first2))
+ ++__first2;
+ }
+ return true;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+ _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
+{
+ return _VSTD::includes(__first1, __last1, __first2, __last2,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_INCLUDES_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
new file mode 100644
index 000000000000..c74633a74cf3
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H
+#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H
+
+#include <__config>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/comp.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/min.h>
+#include <__algorithm/move.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/upper_bound.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <memory>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Predicate>
+class __invert // invert the sense of a comparison
+{
+private:
+ _Predicate __p_;
+public:
+ _LIBCPP_INLINE_VISIBILITY __invert() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __invert(_Predicate __p) : __p_(__p) {}
+
+ template <class _T1>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _T1& __x) {return !__p_(__x);}
+
+ template <class _T1, class _T2>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
+};
+
+template <class _Compare, class _InputIterator1, class _InputIterator2,
+ class _OutputIterator>
+void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2,
+ _OutputIterator __result, _Compare __comp)
+{
+ for (; __first1 != __last1; ++__result)
+ {
+ if (__first2 == __last2)
+ {
+ _VSTD::move(__first1, __last1, __result);
+ return;
+ }
+
+ if (__comp(*__first2, *__first1))
+ {
+ *__result = _VSTD::move(*__first2);
+ ++__first2;
+ }
+ else
+ {
+ *__result = _VSTD::move(*__first1);
+ ++__first1;
+ }
+ }
+ // __first2 through __last2 are already in the right spot.
+}
+
+template <class _Compare, class _BidirectionalIterator>
+void
+__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+ _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
+ if (__len1 <= __len2)
+ {
+ value_type* __p = __buff;
+ for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
+ ::new ((void*)__p) value_type(_VSTD::move(*__i));
+ _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp);
+ }
+ else
+ {
+ value_type* __p = __buff;
+ for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
+ ::new ((void*)__p) value_type(_VSTD::move(*__i));
+ typedef reverse_iterator<_BidirectionalIterator> _RBi;
+ typedef reverse_iterator<value_type*> _Rv;
+ typedef __invert<_Compare> _Inverted;
+ _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
+ _RBi(__middle), _RBi(__first),
+ _RBi(__last), _Inverted(__comp));
+ }
+}
+
+template <class _Compare, class _BidirectionalIterator>
+void
+__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+ _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+ typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+ while (true)
+ {
+ // if __middle == __last, we're done
+ if (__len2 == 0)
+ return;
+ if (__len1 <= __buff_size || __len2 <= __buff_size)
+ return _VSTD::__buffered_inplace_merge<_Compare>
+ (__first, __middle, __last, __comp, __len1, __len2, __buff);
+ // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
+ for (; true; ++__first, (void) --__len1)
+ {
+ if (__len1 == 0)
+ return;
+ if (__comp(*__middle, *__first))
+ break;
+ }
+ // __first < __middle < __last
+ // *__first > *__middle
+ // partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that
+ // all elements in:
+ // [__first, __m1) <= [__middle, __m2)
+ // [__middle, __m2) < [__m1, __middle)
+ // [__m1, __middle) <= [__m2, __last)
+ // and __m1 or __m2 is in the middle of its range
+ _BidirectionalIterator __m1; // "median" of [__first, __middle)
+ _BidirectionalIterator __m2; // "median" of [__middle, __last)
+ difference_type __len11; // distance(__first, __m1)
+ difference_type __len21; // distance(__middle, __m2)
+ // binary search smaller range
+ if (__len1 < __len2)
+ { // __len >= 1, __len2 >= 2
+ __len21 = __len2 / 2;
+ __m2 = __middle;
+ _VSTD::advance(__m2, __len21);
+ __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);
+ __len11 = _VSTD::distance(__first, __m1);
+ }
+ else
+ {
+ if (__len1 == 1)
+ { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1
+ // It is known *__first > *__middle
+ swap(*__first, *__middle);
+ return;
+ }
+ // __len1 >= 2, __len2 >= 1
+ __len11 = __len1 / 2;
+ __m1 = __first;
+ _VSTD::advance(__m1, __len11);
+ __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);
+ __len21 = _VSTD::distance(__middle, __m2);
+ }
+ difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
+ difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
+ // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
+ // swap middle two partitions
+ __middle = _VSTD::rotate(__m1, __middle, __m2);
+ // __len12 and __len21 now have swapped meanings
+ // merge smaller range with recursive call and larger with tail recursion elimination
+ if (__len11 + __len21 < __len12 + __len22)
+ {
+ _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+ __first = __middle;
+ __middle = __m2;
+ __len1 = __len12;
+ __len2 = __len22;
+ }
+ else
+ {
+ _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+ __last = __middle;
+ __middle = __m1;
+ __len1 = __len11;
+ __len2 = __len21;
+ }
+ }
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+ _Compare __comp)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+ difference_type __len1 = _VSTD::distance(__first, __middle);
+ difference_type __len2 = _VSTD::distance(__middle, __last);
+ difference_type __buf_size = _VSTD::min(__len1, __len2);
+ pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
+ unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
+ __buf.first, __buf.second);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
+{
+ _VSTD::inplace_merge(__first, __middle, __last,
+ __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_INPLACE_MERGE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h
new file mode 100644
index 000000000000..bc3682d471aa
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IS_HEAP_H
+#define _LIBCPP___ALGORITHM_IS_HEAP_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/is_heap_until.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _RandomAccessIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ return _VSTD::is_heap_until(__first, __last, __comp) == __last;
+}
+
+template<class _RandomAccessIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ return _VSTD::is_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_IS_HEAP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h b/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h
new file mode 100644
index 000000000000..8c52edb7d498
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
+#define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _RandomAccessIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ difference_type __len = __last - __first;
+ difference_type __p = 0;
+ difference_type __c = 1;
+ _RandomAccessIterator __pp = __first;
+ while (__c < __len)
+ {
+ _RandomAccessIterator __cp = __first + __c;
+ if (__comp(*__pp, *__cp))
+ return __cp;
+ ++__c;
+ ++__cp;
+ if (__c == __len)
+ return __last;
+ if (__comp(*__pp, *__cp))
+ return __cp;
+ ++__p;
+ ++__pp;
+ __c = 2 * __p + 1;
+ }
+ return __last;
+}
+
+template<class _RandomAccessIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_partitioned.h b/contrib/llvm-project/libcxx/include/__algorithm/is_partitioned.h
new file mode 100644
index 000000000000..43de6650cbd4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_partitioned.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IS_PARTITIONED_H
+#define _LIBCPP___ALGORITHM_IS_PARTITIONED_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+ for (; __first != __last; ++__first)
+ if (!__pred(*__first))
+ break;
+ if ( __first == __last )
+ return true;
+ ++__first;
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ return false;
+ return true;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h
new file mode 100644
index 000000000000..0545eb76370a
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_permutation.h
@@ -0,0 +1,168 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IS_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_IS_PERMUTATION_H
+
+#include <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <iterator> // FIXME: replace with <__iterator/distance.h> when it lands
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _BinaryPredicate __pred) {
+ // shorten sequences as much as possible by lopping of any equal prefix
+ for (; __first1 != __last1; ++__first1, (void)++__first2)
+ if (!__pred(*__first1, *__first2))
+ break;
+ if (__first1 == __last1)
+ return true;
+
+ // __first1 != __last1 && *__first1 != *__first2
+ typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
+ _D1 __l1 = _VSTD::distance(__first1, __last1);
+ if (__l1 == _D1(1))
+ return false;
+ _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1);
+ // For each element in [f1, l1) see if there are the same number of
+ // equal elements in [f2, l2)
+ for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) {
+ // Have we already counted the number of *__i in [f1, l1)?
+ _ForwardIterator1 __match = __first1;
+ for (; __match != __i; ++__match)
+ if (__pred(*__match, *__i))
+ break;
+ if (__match == __i) {
+ // Count number of *__i in [f2, l2)
+ _D1 __c2 = 0;
+ for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
+ if (__pred(*__i, *__j))
+ ++__c2;
+ if (__c2 == 0)
+ return false;
+ // Count number of *__i in [__i, l1) (we can start with 1)
+ _D1 __c1 = 1;
+ for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
+ if (__pred(*__i, *__j))
+ ++__c1;
+ if (__c1 != __c2)
+ return false;
+ }
+ }
+ return true;
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
+ typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+ typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+ return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {
+ // shorten sequences as much as possible by lopping of any equal prefix
+ for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
+ if (!__pred(*__first1, *__first2))
+ break;
+ if (__first1 == __last1)
+ return __first2 == __last2;
+ else if (__first2 == __last2)
+ return false;
+
+ typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
+ _D1 __l1 = _VSTD::distance(__first1, __last1);
+
+ typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
+ _D2 __l2 = _VSTD::distance(__first2, __last2);
+ if (__l1 != __l2)
+ return false;
+
+ // For each element in [f1, l1) see if there are the same number of
+ // equal elements in [f2, l2)
+ for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) {
+ // Have we already counted the number of *__i in [f1, l1)?
+ _ForwardIterator1 __match = __first1;
+ for (; __match != __i; ++__match)
+ if (__pred(*__match, *__i))
+ break;
+ if (__match == __i) {
+ // Count number of *__i in [f2, l2)
+ _D1 __c2 = 0;
+ for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
+ if (__pred(*__i, *__j))
+ ++__c2;
+ if (__c2 == 0)
+ return false;
+ // Count number of *__i in [__i, l1) (we can start with 1)
+ _D1 __c1 = 1;
+ for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
+ if (__pred(*__i, *__j))
+ ++__c1;
+ if (__c1 != __c2)
+ return false;
+ }
+ }
+ return true;
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
+ _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
+ _BinaryPredicate __pred, random_access_iterator_tag,
+ random_access_iterator_tag) {
+ if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
+ return false;
+ return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
+ typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2,
+ __pred);
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2, _BinaryPredicate __pred) {
+ return _VSTD::__is_permutation<typename add_lvalue_reference<_BinaryPredicate>::type>(
+ __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category());
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2) {
+ typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+ typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+ return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
+ typename iterator_traits<_ForwardIterator1>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category());
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_IS_PERMUTATION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h
new file mode 100644
index 000000000000..30d8da0499e4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IS_SORTED_H
+#define _LIBCPP___ALGORITHM_IS_SORTED_H
+
+#include <__algorithm/comp.h>
+#include <__algorithm/is_sorted_until.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ return _VSTD::is_sorted_until(__first, __last, __comp) == __last;
+}
+
+template<class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+is_sorted(_ForwardIterator __first, _ForwardIterator __last)
+{
+ return _VSTD::is_sorted(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_IS_SORTED_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h
new file mode 100644
index 000000000000..a914b5a566b6
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
+#define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ while (++__i != __last)
+ {
+ if (__comp(*__i, *__first))
+ return __i;
+ __first = __i;
+ }
+ }
+ return __last;
+}
+
+template<class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
+{
+ return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h b/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h
new file mode 100644
index 000000000000..b63bce62cc0c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ITER_SWAP_H
+#define _LIBCPP___ALGORITHM_ITER_SWAP_H
+
+#include <__config>
+#include <__utility/declval.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_ForwardIterator1 __a,
+ _ForwardIterator2 __b)
+ // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
+ _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {
+ swap(*__a, *__b);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ITER_SWAP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h b/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h
new file mode 100644
index 000000000000..6e4a90bdc03d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
+#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
+{
+ for (; __first2 != __last2; ++__first1, (void) ++__first2)
+ {
+ if (__first1 == __last1 || __comp(*__first1, *__first2))
+ return true;
+ if (__comp(*__first2, *__first1))
+ return false;
+ }
+ return false;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2)
+{
+ return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/lower_bound.h b/contrib/llvm-project/libcxx/include/__algorithm/lower_bound.h
new file mode 100644
index 000000000000..1448c8963327
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/lower_bound.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_LOWER_BOUND_H
+#define _LIBCPP___ALGORITHM_LOWER_BOUND_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/half_positive.h>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+ difference_type __len = _VSTD::distance(__first, __last);
+ while (__len != 0)
+ {
+ difference_type __l2 = _VSTD::__half_positive(__len);
+ _ForwardIterator __m = __first;
+ _VSTD::advance(__m, __l2);
+ if (__comp(*__m, __value_))
+ {
+ __first = ++__m;
+ __len -= __l2 + 1;
+ }
+ else
+ __len = __l2;
+ }
+ return __first;
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
+}
+
+template <class _ForwardIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+ return _VSTD::lower_bound(__first, __last, __value_,
+ __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_LOWER_BOUND_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h
new file mode 100644
index 000000000000..eca4013cbd10
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/make_heap.h
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MAKE_HEAP_H
+#define _LIBCPP___ALGORITHM_MAKE_HEAP_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/sift_down.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ difference_type __n = __last - __first;
+ if (__n > 1)
+ {
+ // start from the first parent, there is no need to consider children
+ for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
+ {
+ _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
+ }
+ }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ _VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/max.h b/contrib/llvm-project/libcxx/include/__algorithm/max.h
new file mode 100644
index 000000000000..2fa97cad87f6
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/max.h
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MAX_H
+#define _LIBCPP___ALGORITHM_MAX_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/max_element.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+max(const _Tp& __a, const _Tp& __b, _Compare __comp)
+{
+ return __comp(__a, __b) ? __b : __a;
+}
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+max(const _Tp& __a, const _Tp& __b)
+{
+ return _VSTD::max(__a, __b, __less<_Tp>());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+max(initializer_list<_Tp> __t, _Compare __comp)
+{
+ return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
+}
+
+template<class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+max(initializer_list<_Tp> __t)
+{
+ return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MAX_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/max_element.h b/contrib/llvm-project/libcxx/include/__algorithm/max_element.h
new file mode 100644
index 000000000000..b93b67eacf57
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/max_element.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MAX_ELEMENT_H
+#define _LIBCPP___ALGORITHM_MAX_ELEMENT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
+ "std::max_element requires a ForwardIterator");
+ if (__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ while (++__i != __last)
+ if (__comp(*__first, *__i))
+ __first = __i;
+ }
+ return __first;
+}
+
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last)
+{
+ return _VSTD::max_element(__first, __last,
+ __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MAX_ELEMENT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/merge.h b/contrib/llvm-project/libcxx/include/__algorithm/merge.h
new file mode 100644
index 000000000000..ea53ad68f7f7
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/merge.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MERGE_H
+#define _LIBCPP___ALGORITHM_MERGE_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+__merge(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ for (; __first1 != __last1; ++__result)
+ {
+ if (__first2 == __last2)
+ return _VSTD::copy(__first1, __last1, __result);
+ if (__comp(*__first2, *__first1))
+ {
+ *__result = *__first2;
+ ++__first2;
+ }
+ else
+ {
+ *__result = *__first1;
+ ++__first1;
+ }
+ }
+ return _VSTD::copy(__first2, __last2, __result);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+merge(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+merge(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+ typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+ typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+ return _VSTD::merge(__first1, __last1, __first2, __last2, __result, __less<__v1, __v2>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MERGE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/min.h b/contrib/llvm-project/libcxx/include/__algorithm/min.h
new file mode 100644
index 000000000000..9fea7f70a2bb
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/min.h
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MIN_H
+#define _LIBCPP___ALGORITHM_MIN_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/min_element.h>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+min(const _Tp& __a, const _Tp& __b, _Compare __comp)
+{
+ return __comp(__b, __a) ? __b : __a;
+}
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+min(const _Tp& __a, const _Tp& __b)
+{
+ return _VSTD::min(__a, __b, __less<_Tp>());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+min(initializer_list<_Tp> __t, _Compare __comp)
+{
+ return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
+}
+
+template<class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+min(initializer_list<_Tp> __t)
+{
+ return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MIN_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/min_element.h b/contrib/llvm-project/libcxx/include/__algorithm/min_element.h
new file mode 100644
index 000000000000..6bff140e5d92
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/min_element.h
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MIN_ELEMENT_H
+#define _LIBCPP___ALGORITHM_MIN_ELEMENT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator
+min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
+ "std::min_element requires a ForwardIterator");
+ if (__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ while (++__i != __last)
+ if (__comp(*__i, *__first))
+ __first = __i;
+ }
+ return __first;
+}
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator
+min_element(_ForwardIterator __first, _ForwardIterator __last)
+{
+ return _VSTD::min_element(__first, __last,
+ __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MIN_ELEMENT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/minmax.h b/contrib/llvm-project/libcxx/include/__algorithm/minmax.h
new file mode 100644
index 000000000000..63753f2fecdc
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/minmax.h
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MINMAX_H
+#define _LIBCPP___ALGORITHM_MINMAX_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <initializer_list>
+#include <utility>
+
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<const _Tp&, const _Tp&>
+minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
+{
+ return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) :
+ pair<const _Tp&, const _Tp&>(__a, __b);
+}
+
+template<class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<const _Tp&, const _Tp&>
+minmax(const _Tp& __a, const _Tp& __b)
+{
+ return _VSTD::minmax(__a, __b, __less<_Tp>());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template<class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Tp, _Tp>
+minmax(initializer_list<_Tp> __t, _Compare __comp)
+{
+ typedef typename initializer_list<_Tp>::const_iterator _Iter;
+ _Iter __first = __t.begin();
+ _Iter __last = __t.end();
+ pair<_Tp, _Tp> __result(*__first, *__first);
+
+ ++__first;
+ if (__t.size() % 2 == 0)
+ {
+ if (__comp(*__first, __result.first))
+ __result.first = *__first;
+ else
+ __result.second = *__first;
+ ++__first;
+ }
+
+ while (__first != __last)
+ {
+ _Tp __prev = *__first++;
+ if (__comp(*__first, __prev)) {
+ if ( __comp(*__first, __result.first)) __result.first = *__first;
+ if (!__comp(__prev, __result.second)) __result.second = __prev;
+ }
+ else {
+ if ( __comp(__prev, __result.first)) __result.first = __prev;
+ if (!__comp(*__first, __result.second)) __result.second = *__first;
+ }
+
+ __first++;
+ }
+ return __result;
+}
+
+template<class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Tp, _Tp>
+minmax(initializer_list<_Tp> __t)
+{
+ return _VSTD::minmax(__t, __less<_Tp>());
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MINMAX_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/minmax_element.h b/contrib/llvm-project/libcxx/include/__algorithm/minmax_element.h
new file mode 100644
index 000000000000..1eba006de9a1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/minmax_element.h
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
+#define _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_ForwardIterator, _ForwardIterator>
+minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
+ "std::minmax_element requires a ForwardIterator");
+ pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
+ if (__first != __last)
+ {
+ if (++__first != __last)
+ {
+ if (__comp(*__first, *__result.first))
+ __result.first = __first;
+ else
+ __result.second = __first;
+ while (++__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ if (++__first == __last)
+ {
+ if (__comp(*__i, *__result.first))
+ __result.first = __i;
+ else if (!__comp(*__i, *__result.second))
+ __result.second = __i;
+ break;
+ }
+ else
+ {
+ if (__comp(*__first, *__i))
+ {
+ if (__comp(*__first, *__result.first))
+ __result.first = __first;
+ if (!__comp(*__i, *__result.second))
+ __result.second = __i;
+ }
+ else
+ {
+ if (__comp(*__i, *__result.first))
+ __result.first = __i;
+ if (!__comp(*__first, *__result.second))
+ __result.second = __first;
+ }
+ }
+ }
+ }
+ }
+ return __result;
+}
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_ForwardIterator, _ForwardIterator>
+minmax_element(_ForwardIterator __first, _ForwardIterator __last)
+{
+ return _VSTD::minmax_element(__first, __last,
+ __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h b/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h
new file mode 100644
index 000000000000..fdd2bc8c09c1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MISMATCH_H
+#define _LIBCPP___ALGORITHM_MISMATCH_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
+ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
+ for (; __first1 != __last1; ++__first1, (void)++__first2)
+ if (!__pred(*__first1, *__first2))
+ break;
+ return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
+}
+
+template <class _InputIterator1, class _InputIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
+ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
+ typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+ typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+ return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
+ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+ _BinaryPredicate __pred) {
+ for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
+ if (!__pred(*__first1, *__first2))
+ break;
+ return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
+}
+
+template <class _InputIterator1, class _InputIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
+ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
+ typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+ typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+ return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MISMATCH_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/move.h b/contrib/llvm-project/libcxx/include/__algorithm/move.h
new file mode 100644
index 000000000000..f5fc74854f05
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/move.h
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MOVE_H
+#define _LIBCPP___ALGORITHM_MOVE_H
+
+#include <__config>
+#include <__algorithm/unwrap_iter.h>
+#include <__utility/move.h>
+#include <cstring>
+#include <utility>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// move
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_OutputIterator
+__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ for (; __first != __last; ++__first, (void) ++__result)
+ *__result = _VSTD::move(*__first);
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_OutputIterator
+__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ return _VSTD::__move_constexpr(__first, __last, __result);
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+typename enable_if
+<
+ is_same<typename remove_const<_Tp>::type, _Up>::value &&
+ is_trivially_move_assignable<_Up>::value,
+ _Up*
+>::type
+__move(_Tp* __first, _Tp* __last, _Up* __result)
+{
+ const size_t __n = static_cast<size_t>(__last - __first);
+ if (__n > 0)
+ _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+ return __result + __n;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ if (__libcpp_is_constant_evaluated()) {
+ return _VSTD::__move_constexpr(__first, __last, __result);
+ } else {
+ return _VSTD::__rewrap_iter(__result,
+ _VSTD::__move(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result)));
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MOVE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
new file mode 100644
index 000000000000..1c93b9819732
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
+#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
+
+#include <__config>
+#include <__algorithm/unwrap_iter.h>
+#include <cstring>
+#include <utility>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_OutputIterator
+__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ while (__first != __last)
+ *--__result = _VSTD::move(*--__last);
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_OutputIterator
+__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ return _VSTD::__move_backward_constexpr(__first, __last, __result);
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+typename enable_if
+<
+ is_same<typename remove_const<_Tp>::type, _Up>::value &&
+ is_trivially_move_assignable<_Up>::value,
+ _Up*
+>::type
+__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
+{
+ const size_t __n = static_cast<size_t>(__last - __first);
+ if (__n > 0)
+ {
+ __result -= __n;
+ _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+ }
+ return __result;
+}
+
+template <class _BidirectionalIterator1, class _BidirectionalIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_BidirectionalIterator2
+move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+ _BidirectionalIterator2 __result)
+{
+ if (__libcpp_is_constant_evaluated()) {
+ return _VSTD::__move_backward_constexpr(__first, __last, __result);
+ } else {
+ return _VSTD::__rewrap_iter(__result,
+ _VSTD::__move_backward(_VSTD::__unwrap_iter(__first),
+ _VSTD::__unwrap_iter(__last),
+ _VSTD::__unwrap_iter(__result)));
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
new file mode 100644
index 000000000000..a337e5efa098
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/reverse.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _BidirectionalIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+ _BidirectionalIterator __i = __last;
+ if (__first == __last || __first == --__i)
+ return false;
+ while (true)
+ {
+ _BidirectionalIterator __ip1 = __i;
+ if (__comp(*--__i, *__ip1))
+ {
+ _BidirectionalIterator __j = __last;
+ while (!__comp(*__i, *--__j))
+ ;
+ swap(*__i, *__j);
+ _VSTD::reverse(__ip1, __last);
+ return true;
+ }
+ if (__i == __first)
+ {
+ _VSTD::reverse(__first, __last);
+ return false;
+ }
+ }
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+ return _VSTD::next_permutation(__first, __last,
+ __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/none_of.h b/contrib/llvm-project/libcxx/include/__algorithm/none_of.h
new file mode 100644
index 000000000000..285691520c4e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/none_of.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_NONE_OF_H
+#define _LIBCPP___ALGORITHM_NONE_OF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ return false;
+ return true;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_NONE_OF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h b/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h
new file mode 100644
index 000000000000..67a03cfc37b0
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h
@@ -0,0 +1,244 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_NTH_ELEMENT_H
+#define _LIBCPP___ALGORITHM_NTH_ELEMENT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/sort.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 bool
+__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
+ _RandomAccessIterator __m, _Compare __comp)
+{
+ // manually guard downward moving __j against __i
+ while (true) {
+ if (__i == --__j) {
+ return false;
+ }
+ if (__comp(*__j, *__m)) {
+ return true; // found guard for downward moving __j, now use unguarded partition
+ }
+ }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
+{
+ // _Compare is known to be a reference type
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ const difference_type __limit = 7;
+ while (true)
+ {
+ if (__nth == __last)
+ return;
+ difference_type __len = __last - __first;
+ switch (__len)
+ {
+ case 0:
+ case 1:
+ return;
+ case 2:
+ if (__comp(*--__last, *__first))
+ swap(*__first, *__last);
+ return;
+ case 3:
+ {
+ _RandomAccessIterator __m = __first;
+ _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp);
+ return;
+ }
+ }
+ if (__len <= __limit)
+ {
+ _VSTD::__selection_sort<_Compare>(__first, __last, __comp);
+ return;
+ }
+ // __len > __limit >= 3
+ _RandomAccessIterator __m = __first + __len/2;
+ _RandomAccessIterator __lm1 = __last;
+ unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp);
+ // *__m is median
+ // partition [__first, __m) < *__m and *__m <= [__m, __last)
+ // (this inhibits tossing elements equivalent to __m around unnecessarily)
+ _RandomAccessIterator __i = __first;
+ _RandomAccessIterator __j = __lm1;
+ // j points beyond range to be tested, *__lm1 is known to be <= *__m
+ // The search going up is known to be guarded but the search coming down isn't.
+ // Prime the downward search with a guard.
+ if (!__comp(*__i, *__m)) // if *__first == *__m
+ {
+ // *__first == *__m, *__first doesn't go in first part
+ if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
+ swap(*__i, *__j);
+ ++__n_swaps;
+ } else {
+ // *__first == *__m, *__m <= all other elements
+ // Partition instead into [__first, __i) == *__first and *__first < [__i, __last)
+ ++__i; // __first + 1
+ __j = __last;
+ if (!__comp(*__first, *--__j)) { // we need a guard if *__first == *(__last-1)
+ while (true) {
+ if (__i == __j) {
+ return; // [__first, __last) all equivalent elements
+ } else if (__comp(*__first, *__i)) {
+ swap(*__i, *__j);
+ ++__n_swaps;
+ ++__i;
+ break;
+ }
+ ++__i;
+ }
+ }
+ // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
+ if (__i == __j) {
+ return;
+ }
+ while (true) {
+ while (!__comp(*__first, *__i))
+ ++__i;
+ while (__comp(*__first, *--__j))
+ ;
+ if (__i >= __j)
+ break;
+ swap(*__i, *__j);
+ ++__n_swaps;
+ ++__i;
+ }
+ // [__first, __i) == *__first and *__first < [__i, __last)
+ // The first part is sorted,
+ if (__nth < __i) {
+ return;
+ }
+ // __nth_element the second part
+ // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp);
+ __first = __i;
+ continue;
+ }
+ }
+ ++__i;
+ // j points beyond range to be tested, *__lm1 is known to be <= *__m
+ // if not yet partitioned...
+ if (__i < __j)
+ {
+ // known that *(__i - 1) < *__m
+ while (true)
+ {
+ // __m still guards upward moving __i
+ while (__comp(*__i, *__m))
+ ++__i;
+ // It is now known that a guard exists for downward moving __j
+ while (!__comp(*--__j, *__m))
+ ;
+ if (__i >= __j)
+ break;
+ swap(*__i, *__j);
+ ++__n_swaps;
+ // It is known that __m != __j
+ // If __m just moved, follow it
+ if (__m == __i)
+ __m = __j;
+ ++__i;
+ }
+ }
+ // [__first, __i) < *__m and *__m <= [__i, __last)
+ if (__i != __m && __comp(*__m, *__i))
+ {
+ swap(*__i, *__m);
+ ++__n_swaps;
+ }
+ // [__first, __i) < *__i and *__i <= [__i+1, __last)
+ if (__nth == __i)
+ return;
+ if (__n_swaps == 0)
+ {
+ // We were given a perfectly partitioned sequence. Coincidence?
+ if (__nth < __i)
+ {
+ // Check for [__first, __i) already sorted
+ __j = __m = __first;
+ while (true) {
+ if (++__j == __i) {
+ // [__first, __i) sorted
+ return;
+ }
+ if (__comp(*__j, *__m)) {
+ // not yet sorted, so sort
+ break;
+ }
+ __m = __j;
+ }
+ }
+ else
+ {
+ // Check for [__i, __last) already sorted
+ __j = __m = __i;
+ while (true) {
+ if (++__j == __last) {
+ // [__i, __last) sorted
+ return;
+ }
+ if (__comp(*__j, *__m)) {
+ // not yet sorted, so sort
+ break;
+ }
+ __m = __j;
+ }
+ }
+ }
+ // __nth_element on range containing __nth
+ if (__nth < __i)
+ {
+ // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp);
+ __last = __i;
+ }
+ else
+ {
+ // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
+ __first = ++__i;
+ }
+ }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)
+{
+ _VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_NTH_ELEMENT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
new file mode 100644
index 000000000000..4f9872c4922b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_H
+#define _LIBCPP___ALGORITHM_PARTIAL_SORT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/make_heap.h>
+#include <__algorithm/sift_down.h>
+#include <__algorithm/sort_heap.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
+__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+ _Compare __comp)
+{
+ _VSTD::__make_heap<_Compare>(__first, __middle, __comp);
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
+ for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
+ {
+ if (__comp(*__i, *__first))
+ {
+ swap(*__i, *__first);
+ _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
+ }
+ }
+ _VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+ _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
+{
+ _VSTD::partial_sort(__first, __middle, __last,
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
new file mode 100644
index 000000000000..31a12615fa5b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
+#define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/make_heap.h>
+#include <__algorithm/sift_down.h>
+#include <__algorithm/sort_heap.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+__partial_sort_copy(_InputIterator __first, _InputIterator __last,
+ _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
+{
+ _RandomAccessIterator __r = __result_first;
+ if (__r != __result_last)
+ {
+ for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
+ *__r = *__first;
+ _VSTD::__make_heap<_Compare>(__result_first, __r, __comp);
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
+ for (; __first != __last; ++__first)
+ if (__comp(*__first, *__result_first))
+ {
+ *__result_first = *__first;
+ _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
+ }
+ _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
+ }
+ return __r;
+}
+
+template <class _InputIterator, class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_RandomAccessIterator
+partial_sort_copy(_InputIterator __first, _InputIterator __last,
+ _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
+}
+
+template <class _InputIterator, class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_RandomAccessIterator
+partial_sort_copy(_InputIterator __first, _InputIterator __last,
+ _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
+{
+ return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last,
+ __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partition.h b/contrib/llvm-project/libcxx/include/__algorithm/partition.h
new file mode 100644
index 000000000000..c859eaca28a3
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partition.h
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PARTITION_H
+#define _LIBCPP___ALGORITHM_PARTITION_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <utility> // pair
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Predicate, class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
+{
+ while (true)
+ {
+ if (__first == __last)
+ return __first;
+ if (!__pred(*__first))
+ break;
+ ++__first;
+ }
+ for (_ForwardIterator __p = __first; ++__p != __last;)
+ {
+ if (__pred(*__p))
+ {
+ swap(*__first, *__p);
+ ++__first;
+ }
+ }
+ return __first;
+}
+
+template <class _Predicate, class _BidirectionalIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator
+__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+ bidirectional_iterator_tag)
+{
+ while (true)
+ {
+ while (true)
+ {
+ if (__first == __last)
+ return __first;
+ if (!__pred(*__first))
+ break;
+ ++__first;
+ }
+ do
+ {
+ if (__first == --__last)
+ return __first;
+ } while (!__pred(*__last));
+ swap(*__first, *__last);
+ ++__first;
+ }
+}
+
+template <class _ForwardIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+ return _VSTD::__partition<typename add_lvalue_reference<_Predicate>::type>
+ (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PARTITION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partition_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/partition_copy.h
new file mode 100644
index 000000000000..445eacdfbe9a
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partition_copy.h
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PARTITION_COPY_H
+#define _LIBCPP___ALGORITHM_PARTITION_COPY_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <utility> // pair
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator1,
+ class _OutputIterator2, class _Predicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
+partition_copy(_InputIterator __first, _InputIterator __last,
+ _OutputIterator1 __out_true, _OutputIterator2 __out_false,
+ _Predicate __pred)
+{
+ for (; __first != __last; ++__first)
+ {
+ if (__pred(*__first))
+ {
+ *__out_true = *__first;
+ ++__out_true;
+ }
+ else
+ {
+ *__out_false = *__first;
+ ++__out_false;
+ }
+ }
+ return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PARTITION_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h b/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h
new file mode 100644
index 000000000000..12ddacf9d756
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PARTITION_POINT_H
+#define _LIBCPP___ALGORITHM_PARTITION_POINT_H
+
+#include <__config>
+#include <__algorithm/half_positive.h>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _ForwardIterator, class _Predicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+ typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+ difference_type __len = _VSTD::distance(__first, __last);
+ while (__len != 0)
+ {
+ difference_type __l2 = _VSTD::__half_positive(__len);
+ _ForwardIterator __m = __first;
+ _VSTD::advance(__m, __l2);
+ if (__pred(*__m))
+ {
+ __first = ++__m;
+ __len -= __l2 + 1;
+ }
+ else
+ __len = __l2;
+ }
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PARTITION_POINT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h
new file mode 100644
index 000000000000..7ebbef25e0ba
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pop_heap.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_POP_HEAP_H
+#define _LIBCPP___ALGORITHM_POP_HEAP_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/sift_down.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len)
+{
+ if (__len > 1)
+ {
+ swap(*__first, *--__last);
+ _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
+ }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ _VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_POP_HEAP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
new file mode 100644
index 000000000000..d6daa73ada00
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
+#define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/reverse.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _BidirectionalIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+ _BidirectionalIterator __i = __last;
+ if (__first == __last || __first == --__i)
+ return false;
+ while (true)
+ {
+ _BidirectionalIterator __ip1 = __i;
+ if (__comp(*__ip1, *--__i))
+ {
+ _BidirectionalIterator __j = __last;
+ while (!__comp(*--__j, *__i))
+ ;
+ swap(*__i, *__j);
+ _VSTD::reverse(__ip1, __last);
+ return true;
+ }
+ if (__i == __first)
+ {
+ _VSTD::reverse(__first, __last);
+ return false;
+ }
+ }
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool
+prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+ return _VSTD::prev_permutation(__first, __last,
+ __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PREV_PERMUTATION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
new file mode 100644
index 000000000000..82a7c123d834
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PUSH_HEAP_H
+#define _LIBCPP___ALGORITHM_PUSH_HEAP_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ if (__len > 1)
+ {
+ __len = (__len - 2) / 2;
+ _RandomAccessIterator __ptr = __first + __len;
+ if (__comp(*__ptr, *--__last))
+ {
+ value_type __t(_VSTD::move(*__last));
+ do
+ {
+ *__last = _VSTD::move(*__ptr);
+ __last = __ptr;
+ if (__len == 0)
+ break;
+ __len = (__len - 1) / 2;
+ __ptr = __first + __len;
+ } while (__comp(*__ptr, __t));
+ *__last = _VSTD::move(__t);
+ }
+ }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ _VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_PUSH_HEAP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove.h b/contrib/llvm-project/libcxx/include/__algorithm/remove.h
new file mode 100644
index 000000000000..4717d7d97310
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REMOVE_H
+#define _LIBCPP___ALGORITHM_REMOVE_H
+
+#include <__config>
+#include <__algorithm/find.h>
+#include <__algorithm/find_if.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+ __first = _VSTD::find(__first, __last, __value_);
+ if (__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ while (++__i != __last)
+ {
+ if (!(*__i == __value_))
+ {
+ *__first = _VSTD::move(*__i);
+ ++__first;
+ }
+ }
+ }
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h
new file mode 100644
index 000000000000..5d2b6403438a
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REMOVE_COPY_H
+#define _LIBCPP___ALGORITHM_REMOVE_COPY_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
+{
+ for (; __first != __last; ++__first)
+ {
+ if (!(*__first == __value_))
+ {
+ *__result = *__first;
+ ++__result;
+ }
+ }
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h
new file mode 100644
index 000000000000..44822564a5cb
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
+#define _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
+{
+ for (; __first != __last; ++__first)
+ {
+ if (!__pred(*__first))
+ {
+ *__result = *__first;
+ ++__result;
+ }
+ }
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h b/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h
new file mode 100644
index 000000000000..e506b4c67fba
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REMOVE_IF_H
+#define _LIBCPP___ALGORITHM_REMOVE_IF_H
+
+#include <__config>
+#include <__algorithm/find_if.h>
+#include <utility>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Predicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+ __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type>
+ (__first, __last, __pred);
+ if (__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ while (++__i != __last)
+ {
+ if (!__pred(*__i))
+ {
+ *__first = _VSTD::move(*__i);
+ ++__first;
+ }
+ }
+ }
+ return __first;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REMOVE_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace.h b/contrib/llvm-project/libcxx/include/__algorithm/replace.h
new file mode 100644
index 000000000000..b723ffeeace4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REPLACE_H
+#define _LIBCPP___ALGORITHM_REPLACE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
+{
+ for (; __first != __last; ++__first)
+ if (*__first == __old_value)
+ *__first = __new_value;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h
new file mode 100644
index 000000000000..1923a57e427c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REPLACE_COPY_H
+#define _LIBCPP___ALGORITHM_REPLACE_COPY_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+ const _Tp& __old_value, const _Tp& __new_value)
+{
+ for (; __first != __last; ++__first, (void) ++__result)
+ if (*__first == __old_value)
+ *__result = __new_value;
+ else
+ *__result = *__first;
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h
new file mode 100644
index 000000000000..72b6f736970c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
+#define _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+ _Predicate __pred, const _Tp& __new_value)
+{
+ for (; __first != __last; ++__first, (void) ++__result)
+ if (__pred(*__first))
+ *__result = __new_value;
+ else
+ *__result = *__first;
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h b/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h
new file mode 100644
index 000000000000..49101a5ce16d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REPLACE_IF_H
+#define _LIBCPP___ALGORITHM_REPLACE_IF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _Predicate, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
+{
+ for (; __first != __last; ++__first)
+ if (__pred(*__first))
+ *__first = __new_value;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REPLACE_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/reverse.h b/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
new file mode 100644
index 000000000000..e538de11472e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REVERSE_H
+#define _LIBCPP___ALGORITHM_REVERSE_H
+
+#include <__config>
+#include <__algorithm/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
+{
+ while (__first != __last)
+ {
+ if (__first == --__last)
+ break;
+ _VSTD::iter_swap(__first, __last);
+ ++__first;
+ }
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
+{
+ if (__first != __last)
+ for (; __first < --__last; ++__first)
+ _VSTD::iter_swap(__first, __last);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+ _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REVERSE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h
new file mode 100644
index 000000000000..48ce60cf8811
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_REVERSE_COPY_H
+#define _LIBCPP___ALGORITHM_REVERSE_COPY_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BidirectionalIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+{
+ for (; __first != __last; ++__result)
+ *__result = *--__last;
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_REVERSE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/rotate.h b/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
new file mode 100644
index 000000000000..0c9ccd7bf7b0
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
@@ -0,0 +1,205 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ROTATE_H
+#define _LIBCPP___ALGORITHM_ROTATE_H
+
+#include <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
+#include <__algorithm/swap_ranges.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__iterator/prev.h>
+#include <__utility/swap.h>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+ value_type __tmp = _VSTD::move(*__first);
+ _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
+ *__lm1 = _VSTD::move(__tmp);
+ return __lm1;
+}
+
+template <class _BidirectionalIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
+__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ _BidirectionalIterator __lm1 = _VSTD::prev(__last);
+ value_type __tmp = _VSTD::move(*__lm1);
+ _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
+ *__first = _VSTD::move(__tmp);
+ return __fp1;
+}
+
+template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
+__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
+{
+ _ForwardIterator __i = __middle;
+ while (true)
+ {
+ swap(*__first, *__i);
+ ++__first;
+ if (++__i == __last)
+ break;
+ if (__first == __middle)
+ __middle = __i;
+ }
+ _ForwardIterator __r = __first;
+ if (__first != __middle)
+ {
+ __i = __middle;
+ while (true)
+ {
+ swap(*__first, *__i);
+ ++__first;
+ if (++__i == __last)
+ {
+ if (__first == __middle)
+ break;
+ __i = __middle;
+ }
+ else if (__first == __middle)
+ __middle = __i;
+ }
+ }
+ return __r;
+}
+
+template<typename _Integral>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
+__algo_gcd(_Integral __x, _Integral __y)
+{
+ do
+ {
+ _Integral __t = __x % __y;
+ __x = __y;
+ __y = __t;
+ } while (__y);
+ return __x;
+}
+
+template<typename _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
+__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+
+ const difference_type __m1 = __middle - __first;
+ const difference_type __m2 = __last - __middle;
+ if (__m1 == __m2)
+ {
+ _VSTD::swap_ranges(__first, __middle, __middle);
+ return __middle;
+ }
+ const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
+ for (_RandomAccessIterator __p = __first + __g; __p != __first;)
+ {
+ value_type __t(_VSTD::move(*--__p));
+ _RandomAccessIterator __p1 = __p;
+ _RandomAccessIterator __p2 = __p1 + __m1;
+ do
+ {
+ *__p1 = _VSTD::move(*__p2);
+ __p1 = __p2;
+ const difference_type __d = __last - __p2;
+ if (__m1 < __d)
+ __p2 += __m1;
+ else
+ __p2 = __first + (__m1 - __d);
+ } while (__p2 != __p);
+ *__p1 = _VSTD::move(__t);
+ }
+ return __first + __m2;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
+ _VSTD::forward_iterator_tag)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+ if (is_trivially_move_assignable<value_type>::value)
+ {
+ if (_VSTD::next(__first) == __middle)
+ return _VSTD::__rotate_left(__first, __last);
+ }
+ return _VSTD::__rotate_forward(__first, __middle, __last);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
+__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+ bidirectional_iterator_tag)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ if (is_trivially_move_assignable<value_type>::value)
+ {
+ if (_VSTD::next(__first) == __middle)
+ return _VSTD::__rotate_left(__first, __last);
+ if (_VSTD::next(__middle) == __last)
+ return _VSTD::__rotate_right(__first, __last);
+ }
+ return _VSTD::__rotate_forward(__first, __middle, __last);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
+__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+ random_access_iterator_tag)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ if (is_trivially_move_assignable<value_type>::value)
+ {
+ if (_VSTD::next(__first) == __middle)
+ return _VSTD::__rotate_left(__first, __last);
+ if (_VSTD::next(__middle) == __last)
+ return _VSTD::__rotate_right(__first, __last);
+ return _VSTD::__rotate_gcd(__first, __middle, __last);
+ }
+ return _VSTD::__rotate_forward(__first, __middle, __last);
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
+{
+ if (__first == __middle)
+ return __last;
+ if (__middle == __last)
+ return __first;
+ return _VSTD::__rotate(__first, __middle, __last,
+ typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ROTATE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h
new file mode 100644
index 000000000000..d5ab7d3b515d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_ROTATE_COPY_H
+#define _LIBCPP___ALGORITHM_ROTATE_COPY_H
+
+#include <__config>
+#include <__algorithm/copy.h>
+#include <iterator>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
+{
+ return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_ROTATE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sample.h b/contrib/llvm-project/libcxx/include/__algorithm/sample.h
new file mode 100644
index 000000000000..2aac6ffa8ceb
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sample.h
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SAMPLE_H
+#define _LIBCPP___ALGORITHM_SAMPLE_H
+
+#include <__config>
+#include <__algorithm/min.h>
+#include <__random/uniform_int_distribution.h>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __output_iter,
+ _Distance __n,
+ _UniformRandomNumberGenerator & __g,
+ input_iterator_tag) {
+
+ _Distance __k = 0;
+ for (; __first != __last && __k < __n; ++__first, (void) ++__k)
+ __output_iter[__k] = *__first;
+ _Distance __sz = __k;
+ for (; __first != __last; ++__first, (void) ++__k) {
+ _Distance __r = uniform_int_distribution<_Distance>(0, __k)(__g);
+ if (__r < __sz)
+ __output_iter[__r] = *__first;
+ }
+ return __output_iter + _VSTD::min(__n, __k);
+}
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __output_iter,
+ _Distance __n,
+ _UniformRandomNumberGenerator& __g,
+ forward_iterator_tag) {
+ _Distance __unsampled_sz = _VSTD::distance(__first, __last);
+ for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
+ _Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
+ if (__r < __n) {
+ *__output_iter++ = *__first;
+ --__n;
+ }
+ }
+ return __output_iter;
+}
+
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+_LIBCPP_INLINE_VISIBILITY
+_SampleIterator __sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __output_iter,
+ _Distance __n, _UniformRandomNumberGenerator& __g) {
+ typedef typename iterator_traits<_PopulationIterator>::iterator_category
+ _PopCategory;
+ typedef typename iterator_traits<_PopulationIterator>::difference_type
+ _Difference;
+ static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
+ __is_cpp17_random_access_iterator<_SampleIterator>::value,
+ "SampleIterator must meet the requirements of RandomAccessIterator");
+ typedef typename common_type<_Distance, _Difference>::type _CommonType;
+ _LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
+ return _VSTD::__sample(
+ __first, __last, __output_iter, _CommonType(__n),
+ __g, _PopCategory());
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _PopulationIterator, class _SampleIterator, class _Distance,
+ class _UniformRandomNumberGenerator>
+inline _LIBCPP_INLINE_VISIBILITY
+_SampleIterator sample(_PopulationIterator __first,
+ _PopulationIterator __last, _SampleIterator __output_iter,
+ _Distance __n, _UniformRandomNumberGenerator&& __g) {
+ return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
+}
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SAMPLE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/search.h b/contrib/llvm-project/libcxx/include/__algorithm/search.h
new file mode 100644
index 000000000000..008b8ebb04ad
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/search.h
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SEARCH_H
+#define _LIBCPP___ALGORITHM_SEARCH_H
+
+#include <__algorithm/comp.h>
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
+pair<_ForwardIterator1, _ForwardIterator1>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) {
+ if (__first2 == __last2)
+ return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence
+ while (true) {
+ // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
+ while (true) {
+ if (__first1 == __last1) // return __last1 if no element matches *__first2
+ return _VSTD::make_pair(__last1, __last1);
+ if (__pred(*__first1, *__first2))
+ break;
+ ++__first1;
+ }
+ // *__first1 matches *__first2, now match elements after here
+ _ForwardIterator1 __m1 = __first1;
+ _ForwardIterator2 __m2 = __first2;
+ while (true) {
+ if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
+ return _VSTD::make_pair(__first1, __m1);
+ if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
+ return _VSTD::make_pair(__last1, __last1);
+ if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
+ {
+ ++__first1;
+ break;
+ } // else there is a match, check next elements
+ }
+ }
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_RandomAccessIterator1, _RandomAccessIterator1>
+__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
+ _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
+ random_access_iterator_tag) {
+ typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
+ typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
+ // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
+ const _D2 __len2 = __last2 - __first2;
+ if (__len2 == 0)
+ return _VSTD::make_pair(__first1, __first1);
+ const _D1 __len1 = __last1 - __first1;
+ if (__len1 < __len2)
+ return _VSTD::make_pair(__last1, __last1);
+ const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
+
+ while (true) {
+ while (true) {
+ if (__first1 == __s)
+ return _VSTD::make_pair(__last1, __last1);
+ if (__pred(*__first1, *__first2))
+ break;
+ ++__first1;
+ }
+
+ _RandomAccessIterator1 __m1 = __first1;
+ _RandomAccessIterator2 __m2 = __first2;
+ while (true) {
+ if (++__m2 == __last2)
+ return _VSTD::make_pair(__first1, __first1 + __len2);
+ ++__m1; // no need to check range on __m1 because __s guarantees we have enough source
+ if (!__pred(*__m1, *__m2)) {
+ ++__first1;
+ break;
+ }
+ }
+ }
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
+search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+ _BinaryPredicate __pred) {
+ return _VSTD::__search<typename add_lvalue_reference<_BinaryPredicate>::type>(
+ __first1, __last1, __first2, __last2, __pred,
+ typename iterator_traits<_ForwardIterator1>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category()).first;
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
+search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
+ typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+ typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+ return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _ForwardIterator, class _Searcher>
+_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
+ return __s(__f, __l).first;
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SEARCH_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/search_n.h b/contrib/llvm-project/libcxx/include/__algorithm/search_n.h
new file mode 100644
index 000000000000..1584e8e613ce
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/search_n.h
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SEARCH_N_H
+#define _LIBCPP___ALGORITHM_SEARCH_N_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last,
+ _Size __count, const _Tp& __value_, _BinaryPredicate __pred,
+ forward_iterator_tag) {
+ if (__count <= 0)
+ return __first;
+ while (true) {
+ // Find first element in sequence that matchs __value_, with a mininum of loop checks
+ while (true) {
+ if (__first == __last) // return __last if no element matches __value_
+ return __last;
+ if (__pred(*__first, __value_))
+ break;
+ ++__first;
+ }
+ // *__first matches __value_, now match elements after here
+ _ForwardIterator __m = __first;
+ _Size __c(0);
+ while (true) {
+ if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
+ return __first;
+ if (++__m == __last) // Otherwise if source exhaused, pattern not found
+ return __last;
+ if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
+ {
+ __first = __m;
+ ++__first;
+ break;
+ } // else there is a match, check next elements
+ }
+ }
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIterator __first,
+ _RandomAccessIterator __last, _Size __count,
+ const _Tp& __value_, _BinaryPredicate __pred,
+ random_access_iterator_tag) {
+ if (__count <= 0)
+ return __first;
+ _Size __len = static_cast<_Size>(__last - __first);
+ if (__len < __count)
+ return __last;
+ const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here
+ while (true) {
+ // Find first element in sequence that matchs __value_, with a mininum of loop checks
+ while (true) {
+ if (__first >= __s) // return __last if no element matches __value_
+ return __last;
+ if (__pred(*__first, __value_))
+ break;
+ ++__first;
+ }
+ // *__first matches __value_, now match elements after here
+ _RandomAccessIterator __m = __first;
+ _Size __c(0);
+ while (true) {
+ if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
+ return __first;
+ ++__m; // no need to check range on __m because __s guarantees we have enough source
+ if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
+ {
+ __first = __m;
+ ++__first;
+ break;
+ } // else there is a match, check next elements
+ }
+ }
+}
+
+template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n(
+ _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) {
+ return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>(
+ __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
+ typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+template <class _ForwardIterator, class _Size, class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) {
+ typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+ return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count), __value_, __equal_to<__v, _Tp>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SEARCH_N_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/set_difference.h b/contrib/llvm-project/libcxx/include/__algorithm/set_difference.h
new file mode 100644
index 000000000000..f4c985d978cd
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/set_difference.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
+#define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ while (__first1 != __last1)
+ {
+ if (__first2 == __last2)
+ return _VSTD::copy(__first1, __last1, __result);
+ if (__comp(*__first1, *__first2))
+ {
+ *__result = *__first1;
+ ++__result;
+ ++__first1;
+ }
+ else
+ {
+ if (!__comp(*__first2, *__first1))
+ ++__first1;
+ ++__first2;
+ }
+ }
+ return __result;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+ return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/set_intersection.h b/contrib/llvm-project/libcxx/include/__algorithm/set_intersection.h
new file mode 100644
index 000000000000..9d34b66c23e3
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/set_intersection.h
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SET_INTERSECTION_H
+#define _LIBCPP___ALGORITHM_SET_INTERSECTION_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ while (__first1 != __last1 && __first2 != __last2)
+ {
+ if (__comp(*__first1, *__first2))
+ ++__first1;
+ else
+ {
+ if (!__comp(*__first2, *__first1))
+ {
+ *__result = *__first1;
+ ++__result;
+ ++__first1;
+ }
+ ++__first2;
+ }
+ }
+ return __result;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+ return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SET_INTERSECTION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/set_symmetric_difference.h b/contrib/llvm-project/libcxx/include/__algorithm/set_symmetric_difference.h
new file mode 100644
index 000000000000..5650b836a611
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/set_symmetric_difference.h
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
+#define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ while (__first1 != __last1)
+ {
+ if (__first2 == __last2)
+ return _VSTD::copy(__first1, __last1, __result);
+ if (__comp(*__first1, *__first2))
+ {
+ *__result = *__first1;
+ ++__result;
+ ++__first1;
+ }
+ else
+ {
+ if (__comp(*__first2, *__first1))
+ {
+ *__result = *__first2;
+ ++__result;
+ }
+ else
+ ++__first1;
+ ++__first2;
+ }
+ }
+ return _VSTD::copy(__first2, __last2, __result);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+ return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/set_union.h b/contrib/llvm-project/libcxx/include/__algorithm/set_union.h
new file mode 100644
index 000000000000..c0874e957461
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/set_union.h
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SET_UNION_H
+#define _LIBCPP___ALGORITHM_SET_UNION_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ for (; __first1 != __last1; ++__result)
+ {
+ if (__first2 == __last2)
+ return _VSTD::copy(__first1, __last1, __result);
+ if (__comp(*__first2, *__first1))
+ {
+ *__result = *__first2;
+ ++__first2;
+ }
+ else
+ {
+ if (!__comp(*__first1, *__first2))
+ ++__first2;
+ *__result = *__first1;
+ ++__first1;
+ }
+ }
+ return _VSTD::copy(__first2, __last2, __result);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_union(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+set_union(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+ return _VSTD::set_union(__first1, __last1, __first2, __last2, __result,
+ __less<typename iterator_traits<_InputIterator1>::value_type,
+ typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SET_UNION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h b/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
new file mode 100644
index 000000000000..961b89cb00ba
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SHIFT_LEFT_H
+#define _LIBCPP___ALGORITHM_SHIFT_LEFT_H
+
+#include <__config>
+#include <__algorithm/move.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+_ForwardIterator
+shift_left(_ForwardIterator __first, _ForwardIterator __last,
+ typename iterator_traits<_ForwardIterator>::difference_type __n)
+{
+ if (__n == 0) {
+ return __last;
+ }
+
+ _ForwardIterator __m = __first;
+ if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
+ if (__n >= __last - __first) {
+ return __first;
+ }
+ __m += __n;
+ } else {
+ for (; __n > 0; --__n) {
+ if (__m == __last) {
+ return __first;
+ }
+ ++__m;
+ }
+ }
+ return _VSTD::move(__m, __last, __first);
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SHIFT_LEFT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h b/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h
new file mode 100644
index 000000000000..5cb41950642c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
+#define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
+
+#include <__config>
+#include <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
+#include <__algorithm/swap_ranges.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+_ForwardIterator
+shift_right(_ForwardIterator __first, _ForwardIterator __last,
+ typename iterator_traits<_ForwardIterator>::difference_type __n)
+{
+ if (__n == 0) {
+ return __first;
+ }
+
+ if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
+ decltype(__n) __d = __last - __first;
+ if (__n >= __d) {
+ return __last;
+ }
+ _ForwardIterator __m = __first + (__d - __n);
+ return _VSTD::move_backward(__first, __m, __last);
+ } else if constexpr (__is_cpp17_bidirectional_iterator<_ForwardIterator>::value) {
+ _ForwardIterator __m = __last;
+ for (; __n > 0; --__n) {
+ if (__m == __first) {
+ return __last;
+ }
+ --__m;
+ }
+ return _VSTD::move_backward(__first, __m, __last);
+ } else {
+ _ForwardIterator __ret = __first;
+ for (; __n > 0; --__n) {
+ if (__ret == __last) {
+ return __last;
+ }
+ ++__ret;
+ }
+
+ // We have an __n-element scratch space from __first to __ret.
+ // Slide an __n-element window [__trail, __lead) from left to right.
+ // We're essentially doing swap_ranges(__first, __ret, __trail, __lead)
+ // over and over; but once __lead reaches __last we needn't bother
+ // to save the values of elements [__trail, __last).
+
+ auto __trail = __first;
+ auto __lead = __ret;
+ while (__trail != __ret) {
+ if (__lead == __last) {
+ _VSTD::move(__first, __trail, __ret);
+ return __ret;
+ }
+ ++__trail;
+ ++__lead;
+ }
+
+ _ForwardIterator __mid = __first;
+ while (true) {
+ if (__lead == __last) {
+ __trail = _VSTD::move(__mid, __ret, __trail);
+ _VSTD::move(__first, __mid, __trail);
+ return __ret;
+ }
+ swap(*__mid, *__trail);
+ ++__mid;
+ ++__trail;
+ ++__lead;
+ if (__mid == __ret) {
+ __mid = __first;
+ }
+ }
+ }
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/shuffle.h b/contrib/llvm-project/libcxx/include/__algorithm/shuffle.h
new file mode 100644
index 000000000000..637fca538857
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/shuffle.h
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SHUFFLE_H
+#define _LIBCPP___ALGORITHM_SHUFFLE_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__random/uniform_int_distribution.h>
+#include <__utility/swap.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
+ || defined(_LIBCPP_BUILDING_LIBRARY)
+class _LIBCPP_TYPE_VIS __rs_default;
+
+_LIBCPP_FUNC_VIS __rs_default __rs_get();
+
+class _LIBCPP_TYPE_VIS __rs_default
+{
+ static unsigned __c_;
+
+ __rs_default();
+public:
+ typedef uint_fast32_t result_type;
+
+ static const result_type _Min = 0;
+ static const result_type _Max = 0xFFFFFFFF;
+
+ __rs_default(const __rs_default&);
+ ~__rs_default();
+
+ result_type operator()();
+
+ static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
+
+ friend _LIBCPP_FUNC_VIS __rs_default __rs_get();
+};
+
+_LIBCPP_FUNC_VIS __rs_default __rs_get();
+
+template <class _RandomAccessIterator>
+_LIBCPP_DEPRECATED_IN_CXX14 void
+random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef uniform_int_distribution<ptrdiff_t> _Dp;
+ typedef typename _Dp::param_type _Pp;
+ difference_type __d = __last - __first;
+ if (__d > 1)
+ {
+ _Dp __uid;
+ __rs_default __g = __rs_get();
+ for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
+ {
+ difference_type __i = __uid(__g, _Pp(0, __d));
+ if (__i != difference_type(0))
+ swap(*__first, *(__first + __i));
+ }
+ }
+}
+
+template <class _RandomAccessIterator, class _RandomNumberGenerator>
+_LIBCPP_DEPRECATED_IN_CXX14 void
+random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
+#ifndef _LIBCPP_CXX03_LANG
+ _RandomNumberGenerator&& __rand)
+#else
+ _RandomNumberGenerator& __rand)
+#endif
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ difference_type __d = __last - __first;
+ if (__d > 1)
+ {
+ for (--__last; __first < __last; ++__first, (void) --__d)
+ {
+ difference_type __i = __rand(__d);
+ if (__i != difference_type(0))
+ swap(*__first, *(__first + __i));
+ }
+ }
+}
+#endif
+
+template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
+ void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
+ _UniformRandomNumberGenerator&& __g)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef uniform_int_distribution<ptrdiff_t> _Dp;
+ typedef typename _Dp::param_type _Pp;
+ difference_type __d = __last - __first;
+ if (__d > 1)
+ {
+ _Dp __uid;
+ for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
+ {
+ difference_type __i = __uid(__g, _Pp(0, __d));
+ if (__i != difference_type(0))
+ swap(*__first, *(__first + __i));
+ }
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SHUFFLE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h b/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
new file mode 100644
index 000000000000..dd4b54ed8e5f
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SIFT_DOWN_H
+#define _LIBCPP___ALGORITHM_SIFT_DOWN_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
+ _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+ _RandomAccessIterator __start)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ // left-child of __start is at 2 * __start + 1
+ // right-child of __start is at 2 * __start + 2
+ difference_type __child = __start - __first;
+
+ if (__len < 2 || (__len - 2) / 2 < __child)
+ return;
+
+ __child = 2 * __child + 1;
+ _RandomAccessIterator __child_i = __first + __child;
+
+ if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
+ // right-child exists and is greater than left-child
+ ++__child_i;
+ ++__child;
+ }
+
+ // check if we are in heap-order
+ if (__comp(*__child_i, *__start))
+ // we are, __start is larger than it's largest child
+ return;
+
+ value_type __top(_VSTD::move(*__start));
+ do
+ {
+ // we are not in heap-order, swap the parent with its largest child
+ *__start = _VSTD::move(*__child_i);
+ __start = __child_i;
+
+ if ((__len - 2) / 2 < __child)
+ break;
+
+ // recompute the child based off of the updated parent
+ __child = 2 * __child + 1;
+ __child_i = __first + __child;
+
+ if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
+ // right-child exists and is greater than left-child
+ ++__child_i;
+ ++__child;
+ }
+
+ // check if we are in heap-order
+ } while (!__comp(*__child_i, __top));
+ *__start = _VSTD::move(__top);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sort.h b/contrib/llvm-project/libcxx/include/__algorithm/sort.h
new file mode 100644
index 000000000000..39ec21302d20
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sort.h
@@ -0,0 +1,530 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SORT_H
+#define _LIBCPP___ALGORITHM_SORT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/min_element.h>
+#include <__algorithm/partial_sort.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__utility/swap.h>
+#include <memory>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// stable, 2-3 compares, 0-2 swaps
+
+template <class _Compare, class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned
+__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c)
+{
+ unsigned __r = 0;
+ if (!__c(*__y, *__x)) // if x <= y
+ {
+ if (!__c(*__z, *__y)) // if y <= z
+ return __r; // x <= y && y <= z
+ // x <= y && y > z
+ swap(*__y, *__z); // x <= z && y < z
+ __r = 1;
+ if (__c(*__y, *__x)) // if x > y
+ {
+ swap(*__x, *__y); // x < y && y <= z
+ __r = 2;
+ }
+ return __r; // x <= y && y < z
+ }
+ if (__c(*__z, *__y)) // x > y, if y > z
+ {
+ swap(*__x, *__z); // x < y && y < z
+ __r = 1;
+ return __r;
+ }
+ swap(*__x, *__y); // x > y && y <= z
+ __r = 1; // x < y && x <= z
+ if (__c(*__z, *__y)) // if y > z
+ {
+ swap(*__y, *__z); // x <= y && y < z
+ __r = 2;
+ }
+ return __r;
+} // x <= y && y <= z
+
+// stable, 3-6 compares, 0-5 swaps
+
+template <class _Compare, class _ForwardIterator>
+unsigned
+__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+ _ForwardIterator __x4, _Compare __c)
+{
+ unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);
+ if (__c(*__x4, *__x3))
+ {
+ swap(*__x3, *__x4);
+ ++__r;
+ if (__c(*__x3, *__x2))
+ {
+ swap(*__x2, *__x3);
+ ++__r;
+ if (__c(*__x2, *__x1))
+ {
+ swap(*__x1, *__x2);
+ ++__r;
+ }
+ }
+ }
+ return __r;
+}
+
+// stable, 4-10 compares, 0-9 swaps
+
+template <class _Compare, class _ForwardIterator>
+_LIBCPP_HIDDEN
+unsigned
+__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+ _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
+{
+ unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
+ if (__c(*__x5, *__x4))
+ {
+ swap(*__x4, *__x5);
+ ++__r;
+ if (__c(*__x4, *__x3))
+ {
+ swap(*__x3, *__x4);
+ ++__r;
+ if (__c(*__x3, *__x2))
+ {
+ swap(*__x2, *__x3);
+ ++__r;
+ if (__c(*__x2, *__x1))
+ {
+ swap(*__x1, *__x2);
+ ++__r;
+ }
+ }
+ }
+ }
+ return __r;
+}
+
+// Assumes size > 0
+template <class _Compare, class _BidirectionalIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 void
+__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+ _BidirectionalIterator __lm1 = __last;
+ for (--__lm1; __first != __lm1; ++__first)
+ {
+ _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator,
+ typename add_lvalue_reference<_Compare>::type>
+ (__first, __last, __comp);
+ if (__i != __first)
+ swap(*__first, *__i);
+ }
+}
+
+template <class _Compare, class _BidirectionalIterator>
+void
+__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ if (__first != __last)
+ {
+ _BidirectionalIterator __i = __first;
+ for (++__i; __i != __last; ++__i)
+ {
+ _BidirectionalIterator __j = __i;
+ value_type __t(_VSTD::move(*__j));
+ for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
+ *__j = _VSTD::move(*__k);
+ *__j = _VSTD::move(__t);
+ }
+ }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __j = __first+2;
+ _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
+ for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
+ {
+ if (__comp(*__i, *__j))
+ {
+ value_type __t(_VSTD::move(*__i));
+ _RandomAccessIterator __k = __j;
+ __j = __i;
+ do
+ {
+ *__j = _VSTD::move(*__k);
+ __j = __k;
+ } while (__j != __first && __comp(__t, *--__k));
+ *__j = _VSTD::move(__t);
+ }
+ __j = __i;
+ }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+bool
+__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ switch (__last - __first)
+ {
+ case 0:
+ case 1:
+ return true;
+ case 2:
+ if (__comp(*--__last, *__first))
+ swap(*__first, *__last);
+ return true;
+ case 3:
+ _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
+ return true;
+ case 4:
+ _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
+ return true;
+ case 5:
+ _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
+ return true;
+ }
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ _RandomAccessIterator __j = __first+2;
+ _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
+ const unsigned __limit = 8;
+ unsigned __count = 0;
+ for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
+ {
+ if (__comp(*__i, *__j))
+ {
+ value_type __t(_VSTD::move(*__i));
+ _RandomAccessIterator __k = __j;
+ __j = __i;
+ do
+ {
+ *__j = _VSTD::move(*__k);
+ __j = __k;
+ } while (__j != __first && __comp(__t, *--__k));
+ *__j = _VSTD::move(__t);
+ if (++__count == __limit)
+ return ++__i == __last;
+ }
+ __j = __i;
+ }
+ return true;
+}
+
+template <class _Compare, class _BidirectionalIterator>
+void
+__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
+ typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ if (__first1 != __last1)
+ {
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
+ value_type* __last2 = __first2;
+ ::new ((void*)__last2) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
+ for (++__last2; ++__first1 != __last1; ++__last2)
+ {
+ value_type* __j2 = __last2;
+ value_type* __i2 = __j2;
+ if (__comp(*__first1, *--__i2))
+ {
+ ::new ((void*)__j2) value_type(_VSTD::move(*__i2));
+ __d.template __incr<value_type>();
+ for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
+ *__j2 = _VSTD::move(*__i2);
+ *__j2 = _VSTD::move(*__first1);
+ }
+ else
+ {
+ ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
+ }
+ }
+ __h.release();
+ }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
+ is_trivially_copy_assignable<value_type>::value ? 30 : 6;
+ while (true)
+ {
+ __restart:
+ difference_type __len = __last - __first;
+ switch (__len)
+ {
+ case 0:
+ case 1:
+ return;
+ case 2:
+ if (__comp(*--__last, *__first))
+ swap(*__first, *__last);
+ return;
+ case 3:
+ _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
+ return;
+ case 4:
+ _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
+ return;
+ case 5:
+ _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
+ return;
+ }
+ if (__len <= __limit)
+ {
+ _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
+ return;
+ }
+ // __len > 5
+ _RandomAccessIterator __m = __first;
+ _RandomAccessIterator __lm1 = __last;
+ --__lm1;
+ unsigned __n_swaps;
+ {
+ difference_type __delta;
+ if (__len >= 1000)
+ {
+ __delta = __len/2;
+ __m += __delta;
+ __delta /= 2;
+ __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp);
+ }
+ else
+ {
+ __delta = __len/2;
+ __m += __delta;
+ __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp);
+ }
+ }
+ // *__m is median
+ // partition [__first, __m) < *__m and *__m <= [__m, __last)
+ // (this inhibits tossing elements equivalent to __m around unnecessarily)
+ _RandomAccessIterator __i = __first;
+ _RandomAccessIterator __j = __lm1;
+ // j points beyond range to be tested, *__m is known to be <= *__lm1
+ // The search going up is known to be guarded but the search coming down isn't.
+ // Prime the downward search with a guard.
+ if (!__comp(*__i, *__m)) // if *__first == *__m
+ {
+ // *__first == *__m, *__first doesn't go in first part
+ // manually guard downward moving __j against __i
+ while (true)
+ {
+ if (__i == --__j)
+ {
+ // *__first == *__m, *__m <= all other elements
+ // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
+ ++__i; // __first + 1
+ __j = __last;
+ if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
+ {
+ while (true)
+ {
+ if (__i == __j)
+ return; // [__first, __last) all equivalent elements
+ if (__comp(*__first, *__i))
+ {
+ swap(*__i, *__j);
+ ++__n_swaps;
+ ++__i;
+ break;
+ }
+ ++__i;
+ }
+ }
+ // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
+ if (__i == __j)
+ return;
+ while (true)
+ {
+ while (!__comp(*__first, *__i))
+ ++__i;
+ while (__comp(*__first, *--__j))
+ ;
+ if (__i >= __j)
+ break;
+ swap(*__i, *__j);
+ ++__n_swaps;
+ ++__i;
+ }
+ // [__first, __i) == *__first and *__first < [__i, __last)
+ // The first part is sorted, sort the second part
+ // _VSTD::__sort<_Compare>(__i, __last, __comp);
+ __first = __i;
+ goto __restart;
+ }
+ if (__comp(*__j, *__m))
+ {
+ swap(*__i, *__j);
+ ++__n_swaps;
+ break; // found guard for downward moving __j, now use unguarded partition
+ }
+ }
+ }
+ // It is known that *__i < *__m
+ ++__i;
+ // j points beyond range to be tested, *__m is known to be <= *__lm1
+ // if not yet partitioned...
+ if (__i < __j)
+ {
+ // known that *(__i - 1) < *__m
+ // known that __i <= __m
+ while (true)
+ {
+ // __m still guards upward moving __i
+ while (__comp(*__i, *__m))
+ ++__i;
+ // It is now known that a guard exists for downward moving __j
+ while (!__comp(*--__j, *__m))
+ ;
+ if (__i > __j)
+ break;
+ swap(*__i, *__j);
+ ++__n_swaps;
+ // It is known that __m != __j
+ // If __m just moved, follow it
+ if (__m == __i)
+ __m = __j;
+ ++__i;
+ }
+ }
+ // [__first, __i) < *__m and *__m <= [__i, __last)
+ if (__i != __m && __comp(*__m, *__i))
+ {
+ swap(*__i, *__m);
+ ++__n_swaps;
+ }
+ // [__first, __i) < *__i and *__i <= [__i+1, __last)
+ // If we were given a perfect partition, see if insertion sort is quick...
+ if (__n_swaps == 0)
+ {
+ bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
+ if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp))
+ {
+ if (__fs)
+ return;
+ __last = __i;
+ continue;
+ }
+ else
+ {
+ if (__fs)
+ {
+ __first = ++__i;
+ continue;
+ }
+ }
+ }
+ // sort smaller range with recursive call and larger with tail recursion elimination
+ if (__i - __first < __last - __i)
+ {
+ _VSTD::__sort<_Compare>(__first, __i, __comp);
+ // _VSTD::__sort<_Compare>(__i+1, __last, __comp);
+ __first = ++__i;
+ }
+ else
+ {
+ _VSTD::__sort<_Compare>(__i+1, __last, __comp);
+ // _VSTD::__sort<_Compare>(__first, __i, __comp);
+ __last = __i;
+ }
+ }
+}
+
+template <class _Compare, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__sort(_Tp** __first, _Tp** __last, __less<_Tp*>&)
+{
+ __less<uintptr_t> __comp;
+ _VSTD::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp);
+}
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ if (__libcpp_is_constant_evaluated()) {
+ _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp));
+ } else {
+ _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp));
+ }
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SORT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h
new file mode 100644
index 000000000000..aa8ef762ab13
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sort_heap.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SORT_HEAP_H
+#define _LIBCPP___ALGORITHM_SORT_HEAP_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/pop_heap.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
+__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
+ _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void
+sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ _VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SORT_HEAP_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h b/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
new file mode 100644
index 000000000000..931335f44474
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H
+#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H
+
+#include <__config>
+#include <__algorithm/rotate.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <memory>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
+_ForwardIterator
+__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
+ _Distance __len, _Pair __p, forward_iterator_tag __fit)
+{
+ // *__first is known to be false
+ // __len >= 1
+ if (__len == 1)
+ return __first;
+ if (__len == 2)
+ {
+ _ForwardIterator __m = __first;
+ if (__pred(*++__m))
+ {
+ swap(*__first, *__m);
+ return __m;
+ }
+ return __first;
+ }
+ if (__len <= __p.second)
+ { // The buffer is big enough to use
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
+ // Move the falses into the temporary buffer, and the trues to the front of the line
+ // Update __first to always point to the end of the trues
+ value_type* __t = __p.first;
+ ::new ((void*)__t) value_type(_VSTD::move(*__first));
+ __d.template __incr<value_type>();
+ ++__t;
+ _ForwardIterator __i = __first;
+ while (++__i != __last)
+ {
+ if (__pred(*__i))
+ {
+ *__first = _VSTD::move(*__i);
+ ++__first;
+ }
+ else
+ {
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
+ __d.template __incr<value_type>();
+ ++__t;
+ }
+ }
+ // All trues now at start of range, all falses in buffer
+ // Move falses back into range, but don't mess up __first which points to first false
+ __i = __first;
+ for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
+ *__i = _VSTD::move(*__t2);
+ // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
+ return __first;
+ }
+ // Else not enough buffer, do in place
+ // __len >= 3
+ _ForwardIterator __m = __first;
+ _Distance __len2 = __len / 2; // __len2 >= 2
+ _VSTD::advance(__m, __len2);
+ // recurse on [__first, __m), *__first know to be false
+ // F?????????????????
+ // f m l
+ typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
+ _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
+ // TTTFFFFF??????????
+ // f ff m l
+ // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
+ _ForwardIterator __m1 = __m;
+ _ForwardIterator __second_false = __last;
+ _Distance __len_half = __len - __len2;
+ while (__pred(*__m1))
+ {
+ if (++__m1 == __last)
+ goto __second_half_done;
+ --__len_half;
+ }
+ // TTTFFFFFTTTF??????
+ // f ff m m1 l
+ __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
+__second_half_done:
+ // TTTFFFFFTTTTTFFFFF
+ // f ff m sf l
+ return _VSTD::rotate(__first_false, __m, __second_false);
+ // TTTTTTTTFFFFFFFFFF
+ // |
+}
+
+template <class _Predicate, class _ForwardIterator>
+_ForwardIterator
+__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
+ forward_iterator_tag)
+{
+ const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment
+ // Either prove all true and return __first or point to first false
+ while (true)
+ {
+ if (__first == __last)
+ return __first;
+ if (!__pred(*__first))
+ break;
+ ++__first;
+ }
+ // We now have a reduced range [__first, __last)
+ // *__first is known to be false
+ typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+ difference_type __len = _VSTD::distance(__first, __last);
+ pair<value_type*, ptrdiff_t> __p(0, 0);
+ unique_ptr<value_type, __return_temporary_buffer> __h;
+ if (__len >= __alloc_limit)
+ {
+ __p = _VSTD::get_temporary_buffer<value_type>(__len);
+ __h.reset(__p.first);
+ }
+ return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
+ (__first, __last, __pred, __len, __p, forward_iterator_tag());
+}
+
+template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
+_BidirectionalIterator
+__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+ _Distance __len, _Pair __p, bidirectional_iterator_tag __bit)
+{
+ // *__first is known to be false
+ // *__last is known to be true
+ // __len >= 2
+ if (__len == 2)
+ {
+ swap(*__first, *__last);
+ return __last;
+ }
+ if (__len == 3)
+ {
+ _BidirectionalIterator __m = __first;
+ if (__pred(*++__m))
+ {
+ swap(*__first, *__m);
+ swap(*__m, *__last);
+ return __last;
+ }
+ swap(*__m, *__last);
+ swap(*__first, *__m);
+ return __m;
+ }
+ if (__len <= __p.second)
+ { // The buffer is big enough to use
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
+ // Move the falses into the temporary buffer, and the trues to the front of the line
+ // Update __first to always point to the end of the trues
+ value_type* __t = __p.first;
+ ::new ((void*)__t) value_type(_VSTD::move(*__first));
+ __d.template __incr<value_type>();
+ ++__t;
+ _BidirectionalIterator __i = __first;
+ while (++__i != __last)
+ {
+ if (__pred(*__i))
+ {
+ *__first = _VSTD::move(*__i);
+ ++__first;
+ }
+ else
+ {
+ ::new ((void*)__t) value_type(_VSTD::move(*__i));
+ __d.template __incr<value_type>();
+ ++__t;
+ }
+ }
+ // move *__last, known to be true
+ *__first = _VSTD::move(*__i);
+ __i = ++__first;
+ // All trues now at start of range, all falses in buffer
+ // Move falses back into range, but don't mess up __first which points to first false
+ for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
+ *__i = _VSTD::move(*__t2);
+ // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
+ return __first;
+ }
+ // Else not enough buffer, do in place
+ // __len >= 4
+ _BidirectionalIterator __m = __first;
+ _Distance __len2 = __len / 2; // __len2 >= 2
+ _VSTD::advance(__m, __len2);
+ // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false
+ // F????????????????T
+ // f m l
+ _BidirectionalIterator __m1 = __m;
+ _BidirectionalIterator __first_false = __first;
+ _Distance __len_half = __len2;
+ while (!__pred(*--__m1))
+ {
+ if (__m1 == __first)
+ goto __first_half_done;
+ --__len_half;
+ }
+ // F???TFFF?????????T
+ // f m1 m l
+ typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
+ __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
+__first_half_done:
+ // TTTFFFFF?????????T
+ // f ff m l
+ // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
+ __m1 = __m;
+ _BidirectionalIterator __second_false = __last;
+ ++__second_false;
+ __len_half = __len - __len2;
+ while (__pred(*__m1))
+ {
+ if (++__m1 == __last)
+ goto __second_half_done;
+ --__len_half;
+ }
+ // TTTFFFFFTTTF?????T
+ // f ff m m1 l
+ __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
+__second_half_done:
+ // TTTFFFFFTTTTTFFFFF
+ // f ff m sf l
+ return _VSTD::rotate(__first_false, __m, __second_false);
+ // TTTTTTTTFFFFFFFFFF
+ // |
+}
+
+template <class _Predicate, class _BidirectionalIterator>
+_BidirectionalIterator
+__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+ bidirectional_iterator_tag)
+{
+ typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+ typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+ const difference_type __alloc_limit = 4; // might want to make this a function of trivial assignment
+ // Either prove all true and return __first or point to first false
+ while (true)
+ {
+ if (__first == __last)
+ return __first;
+ if (!__pred(*__first))
+ break;
+ ++__first;
+ }
+ // __first points to first false, everything prior to __first is already set.
+ // Either prove [__first, __last) is all false and return __first, or point __last to last true
+ do
+ {
+ if (__first == --__last)
+ return __first;
+ } while (!__pred(*__last));
+ // We now have a reduced range [__first, __last]
+ // *__first is known to be false
+ // *__last is known to be true
+ // __len >= 2
+ difference_type __len = _VSTD::distance(__first, __last) + 1;
+ pair<value_type*, ptrdiff_t> __p(0, 0);
+ unique_ptr<value_type, __return_temporary_buffer> __h;
+ if (__len >= __alloc_limit)
+ {
+ __p = _VSTD::get_temporary_buffer<value_type>(__len);
+ __h.reset(__p.first);
+ }
+ return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
+ (__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
+}
+
+template <class _ForwardIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+ return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
+ (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_STABLE_PARTITION_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
new file mode 100644
index 000000000000..32b239a0d72f
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
@@ -0,0 +1,235 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_STABLE_SORT_H
+#define _LIBCPP___ALGORITHM_STABLE_SORT_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/inplace_merge.h>
+#include <__algorithm/sort.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/swap.h>
+#include <memory>
+#include <type_traits> // swap
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _InputIterator1, class _InputIterator2>
+void
+__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2,
+ typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
+{
+ typedef typename iterator_traits<_InputIterator1>::value_type value_type;
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h(__result, __d);
+ for (; true; ++__result)
+ {
+ if (__first1 == __last1)
+ {
+ for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
+ __h.release();
+ return;
+ }
+ if (__first2 == __last2)
+ {
+ for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
+ ::new ((void*)__result) value_type(_VSTD::move(*__first1));
+ __h.release();
+ return;
+ }
+ if (__comp(*__first2, *__first1))
+ {
+ ::new ((void*)__result) value_type(_VSTD::move(*__first2));
+ __d.template __incr<value_type>();
+ ++__first2;
+ }
+ else
+ {
+ ::new ((void*)__result) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
+ ++__first1;
+ }
+ }
+}
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+void
+__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
+ _InputIterator2 __first2, _InputIterator2 __last2,
+ _OutputIterator __result, _Compare __comp)
+{
+ for (; __first1 != __last1; ++__result)
+ {
+ if (__first2 == __last2)
+ {
+ for (; __first1 != __last1; ++__first1, (void) ++__result)
+ *__result = _VSTD::move(*__first1);
+ return;
+ }
+ if (__comp(*__first2, *__first1))
+ {
+ *__result = _VSTD::move(*__first2);
+ ++__first2;
+ }
+ else
+ {
+ *__result = _VSTD::move(*__first1);
+ ++__first1;
+ }
+ }
+ for (; __first2 != __last2; ++__first2, (void) ++__result)
+ *__result = _VSTD::move(*__first2);
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+ typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+ typename iterator_traits<_RandomAccessIterator>::value_type* __first2)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ switch (__len)
+ {
+ case 0:
+ return;
+ case 1:
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ return;
+ case 2:
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
+ if (__comp(*--__last1, *__first1))
+ {
+ ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
+ __d.template __incr<value_type>();
+ ++__first2;
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ }
+ else
+ {
+ ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
+ __d.template __incr<value_type>();
+ ++__first2;
+ ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
+ }
+ __h2.release();
+ return;
+ }
+ if (__len <= 8)
+ {
+ _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
+ return;
+ }
+ typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
+ _RandomAccessIterator __m = __first1 + __l2;
+ _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
+ _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
+ _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
+}
+
+template <class _Tp>
+struct __stable_sort_switch
+{
+ static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;
+};
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+ typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+ typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ switch (__len)
+ {
+ case 0:
+ case 1:
+ return;
+ case 2:
+ if (__comp(*--__last, *__first))
+ swap(*__first, *__last);
+ return;
+ }
+ if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
+ {
+ _VSTD::__insertion_sort<_Compare>(__first, __last, __comp);
+ return;
+ }
+ typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
+ _RandomAccessIterator __m = __first + __l2;
+ if (__len <= __buff_size)
+ {
+ __destruct_n __d(0);
+ unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
+ _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
+ __d.__set(__l2, (value_type*)nullptr);
+ _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
+ __d.__set(__len, (value_type*)nullptr);
+ _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
+// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
+// move_iterator<value_type*>(__buff + __l2),
+// move_iterator<_RandomAccessIterator>(__buff + __l2),
+// move_iterator<_RandomAccessIterator>(__buff + __len),
+// __first, __comp);
+ return;
+ }
+ _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
+ _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
+ _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+ difference_type __len = __last - __first;
+ pair<value_type*, ptrdiff_t> __buf(0, 0);
+ unique_ptr<value_type, __return_temporary_buffer> __h;
+ if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value))
+ {
+ __buf = _VSTD::get_temporary_buffer<value_type>(__len);
+ __h.reset(__buf.first);
+ }
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+ _VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_STABLE_SORT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h b/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
new file mode 100644
index 000000000000..3c72dbd24c63
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_SWAP_RANGES_H
+#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
+
+#include <__config>
+#include <__utility/swap.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2
+swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
+ for (; __first1 != __last1; ++__first1, (void)++__first2)
+ swap(*__first1, *__first2);
+ return __first2;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/transform.h b/contrib/llvm-project/libcxx/include/__algorithm/transform.h
new file mode 100644
index 000000000000..218f0f12eaca
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/transform.h
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_TRANSFORM_H
+#define _LIBCPP___ALGORITHM_TRANSFORM_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
+{
+ for (; __first != __last; ++__first, (void) ++__result)
+ *__result = __op(*__first);
+ return __result;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
+ _OutputIterator __result, _BinaryOperation __binary_op)
+{
+ for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result)
+ *__result = __binary_op(*__first1, *__first2);
+ return __result;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_TRANSFORM_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unique.h b/contrib/llvm-project/libcxx/include/__algorithm/unique.h
new file mode 100644
index 000000000000..fb6251a39a82
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unique.h
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_UNIQUE_H
+#define _LIBCPP___ALGORITHM_UNIQUE_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/adjacent_find.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// unique
+
+template <class _ForwardIterator, class _BinaryPredicate>
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
+{
+ __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type>
+ (__first, __last, __pred);
+ if (__first != __last)
+ {
+ // ... a a ? ...
+ // f i
+ _ForwardIterator __i = __first;
+ for (++__i; ++__i != __last;)
+ if (!__pred(*__first, *__i))
+ *++__first = _VSTD::move(*__i);
+ ++__first;
+ }
+ return __first;
+}
+
+template <class _ForwardIterator>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+ return _VSTD::unique(__first, __last, __equal_to<__v>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_UNIQUE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h
new file mode 100644
index 000000000000..974a7c4df2d4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unique_copy.h
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_UNIQUE_COPY_H
+#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__iterator/iterator_traits.h>
+#include <utility>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
+ input_iterator_tag, output_iterator_tag)
+{
+ if (__first != __last)
+ {
+ typename iterator_traits<_InputIterator>::value_type __t(*__first);
+ *__result = __t;
+ ++__result;
+ while (++__first != __last)
+ {
+ if (!__pred(__t, *__first))
+ {
+ __t = *__first;
+ *__result = __t;
+ ++__result;
+ }
+ }
+ }
+ return __result;
+}
+
+template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
+__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
+ forward_iterator_tag, output_iterator_tag)
+{
+ if (__first != __last)
+ {
+ _ForwardIterator __i = __first;
+ *__result = *__i;
+ ++__result;
+ while (++__first != __last)
+ {
+ if (!__pred(*__i, *__first))
+ {
+ *__result = *__first;
+ ++__result;
+ __i = __first;
+ }
+ }
+ }
+ return __result;
+}
+
+template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
+ input_iterator_tag, forward_iterator_tag)
+{
+ if (__first != __last)
+ {
+ *__result = *__first;
+ while (++__first != __last)
+ if (!__pred(*__result, *__first))
+ *++__result = *__first;
+ ++__result;
+ }
+ return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
+{
+ return _VSTD::__unique_copy<typename add_lvalue_reference<_BinaryPredicate>::type>
+ (__first, __last, __result, __pred,
+ typename iterator_traits<_InputIterator>::iterator_category(),
+ typename iterator_traits<_OutputIterator>::iterator_category());
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+ typedef typename iterator_traits<_InputIterator>::value_type __v;
+ return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
+}
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h
new file mode 100644
index 000000000000..a45d45cdd864
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_UNWRAP_ITER_H
+#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H
+
+#include <__config>
+#include <iterator>
+#include <__memory/pointer_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// The job of __unwrap_iter is to lower contiguous iterators (such as
+// vector<T>::iterator) into pointers, to reduce the number of template
+// instantiations and to enable pointer-based optimizations e.g. in std::copy.
+// For iterators that are not contiguous, it must be a no-op.
+// In debug mode, we don't do this.
+//
+// __unwrap_iter is non-constexpr for user-defined iterators whose
+// `to_address` and/or `operator->` is non-constexpr. This is okay; but we
+// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway.
+//
+// Some algorithms (e.g. std::copy, but not std::sort) need to convert an
+// "unwrapped" result back into a contiguous iterator. Since contiguous iterators
+// are random-access, we can do this portably using iterator arithmetic; this
+// is the job of __rewrap_iter.
+
+template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value>
+struct __unwrap_iter_impl {
+ static _LIBCPP_CONSTEXPR _Iter
+ __apply(_Iter __i) _NOEXCEPT {
+ return __i;
+ }
+};
+
+#if _LIBCPP_DEBUG_LEVEL < 2
+
+template <class _Iter>
+struct __unwrap_iter_impl<_Iter, true> {
+ static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>()))
+ __apply(_Iter __i) _NOEXCEPT {
+ return _VSTD::__to_address(__i);
+ }
+};
+
+#endif // _LIBCPP_DEBUG_LEVEL < 2
+
+template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+decltype(_Impl::__apply(declval<_Iter>()))
+__unwrap_iter(_Iter __i) _NOEXCEPT
+{
+ return _Impl::__apply(__i);
+}
+
+template<class _OrigIter>
+_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
+{
+ return __result;
+}
+
+template<class _OrigIter, class _UnwrappedIter>
+_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
+{
+ // Precondition: __result is reachable from __first
+ // Precondition: _OrigIter is a contiguous iterator
+ return __first + (__result - _VSTD::__unwrap_iter(__first));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/upper_bound.h b/contrib/llvm-project/libcxx/include/__algorithm/upper_bound.h
new file mode 100644
index 000000000000..7be607f82538
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/upper_bound.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_UPPER_BOUND_H
+#define _LIBCPP___ALGORITHM_UPPER_BOUND_H
+
+#include <__config>
+#include <__algorithm/comp.h>
+#include <__algorithm/half_positive.h>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+ difference_type __len = _VSTD::distance(__first, __last);
+ while (__len != 0)
+ {
+ difference_type __l2 = _VSTD::__half_positive(__len);
+ _ForwardIterator __m = __first;
+ _VSTD::advance(__m, __l2);
+ if (__comp(__value_, *__m))
+ __len = __l2;
+ else
+ {
+ __first = ++__m;
+ __len -= __l2 + 1;
+ }
+ }
+ return __first;
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+ typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
+}
+
+template <class _ForwardIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator
+upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+ return _VSTD::upper_bound(__first, __last, __value_,
+ __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ALGORITHM_UPPER_BOUND_H
diff --git a/contrib/llvm-project/libcxx/include/__availability b/contrib/llvm-project/libcxx/include/__availability
index cc3b6fabdab1..13d11950fd67 100644
--- a/contrib/llvm-project/libcxx/include/__availability
+++ b/contrib/llvm-project/libcxx/include/__availability
@@ -138,6 +138,13 @@
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
+ // This controls the availability of the C++20 format library.
+ // The library is in development and not ABI stable yet. Currently
+ // P2216 is aiming to be retroactively accepted in C++20. This paper
+ // contains ABI breaking changes.
+# define _LIBCPP_AVAILABILITY_FORMAT
+// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
+
#elif defined(__APPLE__)
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
@@ -215,14 +222,28 @@
# define _LIBCPP_AVAILABILITY_TO_CHARS \
_LIBCPP_AVAILABILITY_FILESYSTEM
- // Note: Those are not ABI-stable yet, so we can't ship them.
# define _LIBCPP_AVAILABILITY_SYNC \
- __attribute__((unavailable))
-# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait
-# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier
-# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
-# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
+ __attribute__((availability(macosx,strict,introduced=11.0))) \
+ __attribute__((availability(ios,strict,introduced=14.0))) \
+ __attribute__((availability(tvos,strict,introduced=14.0))) \
+ __attribute__((availability(watchos,strict,introduced=7.0)))
+# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
+ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
+ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
+ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
+# endif
+ // This controls the availability of the C++20 format library.
+ // The library is in development and not ABI stable yet. Currently
+ // P2216 is aiming to be retroactively accepted in C++20. This paper
+ // contains ABI breaking changes.
+# define _LIBCPP_AVAILABILITY_FORMAT \
+ __attribute__((unavailable))
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
#else
// ...New vendors can add availability markup here...
@@ -246,4 +267,4 @@
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
-#endif // _LIBCPP___AVAILABILITY
+#endif // _LIBCPP___AVAILABILITY
diff --git a/contrib/llvm-project/libcxx/include/__bit_reference b/contrib/llvm-project/libcxx/include/__bit_reference
index d44ad03d3134..a02492c077dd 100644
--- a/contrib/llvm-project/libcxx/include/__bit_reference
+++ b/contrib/llvm-project/libcxx/include/__bit_reference
@@ -1300,4 +1300,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___BIT_REFERENCE
+#endif // _LIBCPP___BIT_REFERENCE
diff --git a/contrib/llvm-project/libcxx/include/__bits b/contrib/llvm-project/libcxx/include/__bits
index 0d321da92285..b565a782358c 100644
--- a/contrib/llvm-project/libcxx/include/__bits
+++ b/contrib/llvm-project/libcxx/include/__bits
@@ -76,7 +76,6 @@ inline _LIBCPP_INLINE_VISIBILITY
int __libcpp_ctz(unsigned long long __x) {
unsigned long __where;
#if defined(_LIBCPP_HAS_BITSCAN64)
- (defined(_M_AMD64) || defined(__x86_64__))
if (_BitScanForward64(&__where, __x))
return static_cast<int>(__where);
#else
@@ -143,4 +142,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP__BITS
+#endif // _LIBCPP___BITS
diff --git a/contrib/llvm-project/libcxx/include/__bsd_locale_fallbacks.h b/contrib/llvm-project/libcxx/include/__bsd_locale_fallbacks.h
index a807fe039554..ed0eabf60ece 100644
--- a/contrib/llvm-project/libcxx/include/__bsd_locale_fallbacks.h
+++ b/contrib/llvm-project/libcxx/include/__bsd_locale_fallbacks.h
@@ -13,9 +13,9 @@
#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
-#include <stdlib.h>
-#include <stdarg.h>
#include <memory>
+#include <stdarg.h>
+#include <stdlib.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
diff --git a/contrib/llvm-project/libcxx/include/__config b/contrib/llvm-project/libcxx/include/__config
index a3838c89e8e1..3cf23694f878 100644
--- a/contrib/llvm-project/libcxx/include/__config
+++ b/contrib/llvm-project/libcxx/include/__config
@@ -10,6 +10,8 @@
#ifndef _LIBCPP_CONFIG
#define _LIBCPP_CONFIG
+#include <__config_site>
+
#if defined(_MSC_VER) && !defined(__clang__)
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
@@ -32,7 +34,7 @@
# define _GNUC_VER_NEW 0
#endif
-#define _LIBCPP_VERSION 12000
+#define _LIBCPP_VERSION 13000
#ifndef _LIBCPP_ABI_VERSION
# define _LIBCPP_ABI_VERSION 1
@@ -54,7 +56,7 @@
# else
# define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification
# endif
-#endif // _LIBCPP_STD_VER
+#endif // _LIBCPP_STD_VER
#if defined(__ELF__)
# define _LIBCPP_OBJECT_FORMAT_ELF 1
@@ -86,17 +88,18 @@
// provided under the alternate keyword __nullptr, which changes the mangling
// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
-// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
-// instead of as a class simulating an enum. If this option is enabled
-// `pointer_safety` and `get_pointer_safety()` will no longer be available
-// in C++03.
-# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
// Define a key function for `bad_function_call` in the library, to centralize
// its vtable and typeinfo to libc++ rather than having all other libraries
// using that class define their own copies.
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
+// In C++20 and later, don't derive std::plus from std::binary_function,
+// nor std::negate from std::unary_function.
+# define _LIBCPP_ABI_NO_BINDER_BASES
+// Give reverse_iterator<T> one data member of type T, not two.
+// Also, in C++17 and later, don't derive iterator types from std::iterator.
+# define _LIBCPP_ABI_NO_ITERATOR_BASES
// Use the smallest possible integer type to represent the index of the variant.
// Previously libc++ used "unsigned int" exclusively.
# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
@@ -104,6 +107,8 @@
# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
// All the regex constants must be distinct and nonzero.
# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
+// Use raw pointers, not wrapped ones, for std::span's iterator type.
+# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS
// Re-worked external template instantiations for std::string with a focus on
// performance and fast-path inlining.
# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
@@ -181,11 +186,12 @@
#define __has_include(...) 0
#endif
-#if defined(__clang__)
-# define _LIBCPP_COMPILER_CLANG
-# ifndef __apple_build_version__
-# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
-# endif
+#if defined(__apple_build_version__)
+# define _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
+#elif defined(__clang__)
+# define _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
#elif defined(__GNUC__)
# define _LIBCPP_COMPILER_GCC
#elif defined(_MSC_VER)
@@ -235,13 +241,13 @@
# if __LITTLE_ENDIAN__
# define _LIBCPP_LITTLE_ENDIAN
# endif // __LITTLE_ENDIAN__
-#endif // __LITTLE_ENDIAN__
+#endif // __LITTLE_ENDIAN__
#ifdef __BIG_ENDIAN__
# if __BIG_ENDIAN__
# define _LIBCPP_BIG_ENDIAN
# endif // __BIG_ENDIAN__
-#endif // __BIG_ENDIAN__
+#endif // __BIG_ENDIAN__
#ifdef __BYTE_ORDER__
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
@@ -262,7 +268,7 @@
# ifndef __LONG_LONG_SUPPORTED
# define _LIBCPP_HAS_NO_LONG_LONG
# endif // __LONG_LONG_SUPPORTED
-#endif // __FreeBSD__
+#endif // __FreeBSD__
#if defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/endian.h>
@@ -271,7 +277,7 @@
# else // _BYTE_ORDER == _LITTLE_ENDIAN
# define _LIBCPP_BIG_ENDIAN
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-#endif // defined(__NetBSD__) || defined(__OpenBSD__)
+#endif // defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(_WIN32)
# define _LIBCPP_WIN32API
@@ -340,7 +346,7 @@
# else // __BYTE_ORDER == __BIG_ENDIAN
# error unable to determine endian
# endif
-#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
+#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
@@ -348,7 +354,7 @@
# define _LIBCPP_NO_CFI
#endif
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L
# if defined(__FreeBSD__)
# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_QUICK_EXIT
@@ -387,13 +393,16 @@
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_TIMESPEC_GET
# endif
+# elif defined(_LIBCPP_MSVCRT)
+ // Using Microsoft's C Runtime library, not MinGW
+# define _LIBCPP_HAS_TIMESPEC_GET
# elif defined(__APPLE__)
// timespec_get and aligned_alloc were introduced in macOS 10.15 and
// aligned releases
-# if (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 || \
- __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
- __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000 || \
- __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)
+# if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \
+ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
+ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \
+ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000))
# define _LIBCPP_HAS_ALIGNED_ALLOC
# define _LIBCPP_HAS_TIMESPEC_GET
# endif
@@ -402,7 +411,7 @@
#ifndef _LIBCPP_CXX03_LANG
# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp)
-#elif defined(_LIBCPP_COMPILER_CLANG)
+#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
#else
# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang"
@@ -410,7 +419,7 @@
#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
-#if defined(_LIBCPP_COMPILER_CLANG)
+#if defined(_LIBCPP_COMPILER_CLANG_BASED)
#if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
# error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead
@@ -484,12 +493,12 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_NOEXCEPT
#endif
-#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
+#if !__has_feature(address_sanitizer)
#define _LIBCPP_HAS_NO_ASAN
#endif
// Allow for build-time disabling of unsigned integer sanitization
-#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize)
+#if __has_attribute(no_sanitize)
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
#endif
@@ -508,8 +517,8 @@ typedef __char32_t char32_t;
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1
-#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
- (defined(__apple_build_version__) && __apple_build_version__ < 10010000)
+#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \
+ (defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1001)
#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS
#endif
@@ -522,7 +531,7 @@ typedef __char32_t char32_t;
#define _LIBCPP_NORETURN __attribute__((noreturn))
-#if !__EXCEPTIONS
+#if !defined(__EXCEPTIONS)
# define _LIBCPP_NO_EXCEPTIONS
#endif
@@ -536,7 +545,7 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#endif
-#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
+#if !defined(__SANITIZE_ADDRESS__)
#define _LIBCPP_HAS_NO_ASAN
#endif
@@ -640,6 +649,7 @@ typedef __char32_t char32_t;
#define _LIBCPP_HIDDEN
#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
#define _LIBCPP_TEMPLATE_VIS
+#define _LIBCPP_TEMPLATE_DATA_VIS
#define _LIBCPP_ENUM_VIS
#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
@@ -689,6 +699,14 @@ typedef __char32_t char32_t;
# endif
#endif
+#ifndef _LIBCPP_TEMPLATE_DATA_VIS
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default")))
+# else
+# define _LIBCPP_TEMPLATE_DATA_VIS
+# endif
+#endif
+
#ifndef _LIBCPP_EXPORTED_FROM_ABI
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
@@ -792,10 +810,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
#define _VSTD_FS _VSTD::__fs::filesystem
-#ifndef _LIBCPP_PREFERRED_OVERLOAD
-# if __has_attribute(__enable_if__)
-# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
-# endif
+#if __has_attribute(__enable_if__)
+# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
#endif
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
@@ -809,7 +825,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef unsigned short char16_t;
typedef unsigned int char32_t;
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
#ifndef __SIZEOF_INT128__
#define _LIBCPP_HAS_NO_INT128
@@ -818,7 +834,7 @@ typedef unsigned int char32_t;
#ifdef _LIBCPP_CXX03_LANG
# define static_assert(...) _Static_assert(__VA_ARGS__)
# define decltype(...) __decltype(__VA_ARGS__)
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
#ifdef _LIBCPP_CXX03_LANG
# define _LIBCPP_CONSTEXPR
@@ -832,6 +848,14 @@ typedef unsigned int char32_t;
# define _LIBCPP_CONSTEVAL consteval
#endif
+#if !defined(__cpp_concepts) || __cpp_concepts < 201907L
+#define _LIBCPP_HAS_NO_CONCEPTS
+#endif
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS)
+#define _LIBCPP_HAS_NO_RANGES
+#endif
+
#ifdef _LIBCPP_CXX03_LANG
# define _LIBCPP_DEFAULT {}
#else
@@ -850,11 +874,10 @@ typedef unsigned int char32_t;
# define _LIBCPP_NOALIAS
#endif
-#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
- (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
-# define _LIBCPP_EXPLICIT explicit
+#if __has_attribute(using_if_exists)
+# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
#else
-# define _LIBCPP_EXPLICIT
+# define _LIBCPP_USING_IF_EXISTS
#endif
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
@@ -868,7 +891,7 @@ typedef unsigned int char32_t;
#else // _LIBCPP_HAS_NO_STRONG_ENUMS
# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
-#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
+#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
// _LIBCPP_DEBUG potential values:
// - undefined: No assertions. This is the default.
@@ -884,33 +907,25 @@ typedef unsigned int char32_t;
# error Supported values for _LIBCPP_DEBUG are 0 and 1
#endif
-// _LIBCPP_DEBUG_LEVEL is always defined to one of [0, 1, 2] at this point
-#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
-# define _LIBCPP_EXTERN_TEMPLATE(...)
-#endif
-
-#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
-# define _LIBCPP_EXTERN_TEMPLATE(...)
-# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...)
-#endif
-
-#ifndef _LIBCPP_EXTERN_TEMPLATE
-#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
-#endif
-
-// When the Debug mode is enabled, we disable extern declarations because we
-// don't want to use the functions compiled in the library, which might not
-// have had the debug mode enabled when built. However, some extern declarations
-// need to be used, because code correctness depends on it (several instances
-// in the <locale>). Those special declarations are declared with
-// _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled even
-// when the debug mode is enabled.
-#ifndef _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE
-# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
-#endif
-
-#ifndef _LIBCPP_EXTERN_TEMPLATE_DEFINE
-#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
+// Libc++ allows disabling extern template instantiation declarations by
+// means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE.
+//
+// Furthermore, when the Debug mode is enabled, we disable extern declarations
+// when building user code because we don't want to use the functions compiled
+// in the library, which might not have had the debug mode enabled when built.
+// However, some extern declarations need to be used, because code correctness
+// depends on it (several instances in <locale>). Those special declarations
+// are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled
+// even when the debug mode is enabled.
+#if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE)
+# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
+# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */
+#elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY)
+# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */
+# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
+#else
+# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__;
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
@@ -918,13 +933,6 @@ typedef unsigned int char32_t;
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-// Most unix variants have catopen. These are the specific ones that don't.
-# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
-# define _LIBCPP_HAS_CATOPEN 1
-# endif
-#endif
-
#ifdef __FreeBSD__
#define _DECLARE_C99_LDBL_MATH 1
#endif
@@ -948,9 +956,8 @@ typedef unsigned int char32_t;
# endif
#endif // defined(__APPLE__)
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \
- (defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
- (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606))
+#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \
+ (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#endif
@@ -963,7 +970,7 @@ typedef unsigned int char32_t;
#endif
#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
-#define _LIBCPP_NO_HAS_CHAR8_T
+#define _LIBCPP_HAS_NO_CHAR8_T
#endif
// Deprecation macros.
@@ -1006,24 +1013,23 @@ typedef unsigned int char32_t;
# define _LIBCPP_DEPRECATED_IN_CXX20
#endif
-#if !defined(_LIBCPP_NO_HAS_CHAR8_T)
+#if !defined(_LIBCPP_HAS_NO_CHAR8_T)
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
#else
# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
#endif
// Macros to enter and leave a state where deprecation warnings are suppressed.
-#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH) && \
- (defined(_LIBCPP_COMPILER_CLANG) || defined(_LIBCPP_COMPILER_GCC))
-# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
-# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
- _Pragma("GCC diagnostic pop")
-#endif
-#if !defined(_LIBCPP_SUPPRESS_DEPRECATED_PUSH)
-# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
-# define _LIBCPP_SUPPRESS_DEPRECATED_POP
+#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+# define _LIBCPP_SUPPRESS_DEPRECATED_POP \
+ _Pragma("GCC diagnostic pop")
+#else
+# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+# define _LIBCPP_SUPPRESS_DEPRECATED_POP
#endif
#if _LIBCPP_STD_VER <= 11
@@ -1054,7 +1060,7 @@ typedef unsigned int char32_t;
// NODISCARD macros to the correct attribute.
#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]]
-#elif defined(_LIBCPP_COMPILER_CLANG) && !defined(_LIBCPP_CXX03_LANG)
+#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
# define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]]
#else
// We can't use GCC's [[gnu::warn_unused_result]] and
@@ -1084,12 +1090,10 @@ typedef unsigned int char32_t;
# define _LIBCPP_INLINE_VAR
#endif
-#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG
#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
-#define _LIBCPP_CONSTEXPR_IF_NODEBUG
+# define _LIBCPP_CONSTEXPR_IF_NODEBUG
#else
-#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
-#endif
+# define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr
#endif
#if __has_attribute(no_destroy)
@@ -1104,7 +1108,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#endif
// Try to find out if RTTI is disabled.
-#if defined(_LIBCPP_COMPILER_CLANG) && !__has_feature(cxx_rtti)
+#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti)
# define _LIBCPP_NO_RTTI
#elif defined(__GNUC__) && !defined(__GXX_RTTI)
# define _LIBCPP_NO_RTTI
@@ -1132,6 +1136,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
defined(__CloudABI__) || \
defined(__sun__) || \
defined(__MVS__) || \
+ defined(_AIX) || \
(defined(__MINGW32__) && __has_include(<pthread.h>))
# define _LIBCPP_HAS_THREAD_API_PTHREAD
# elif defined(__Fuchsia__)
@@ -1218,12 +1223,10 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#endif
// Some systems do not provide gets() in their C library, for security reasons.
-#ifndef _LIBCPP_C_HAS_NO_GETS
-# if defined(_LIBCPP_MSVCRT) || \
- (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
- defined(__OpenBSD__)
-# define _LIBCPP_C_HAS_NO_GETS
-# endif
+#if defined(_LIBCPP_MSVCRT) || \
+ (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
+ defined(__OpenBSD__)
+# define _LIBCPP_C_HAS_NO_GETS
#endif
#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \
@@ -1273,13 +1276,11 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
# endif
#endif
-#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION
-# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
-# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
-# else
-# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
-# endif
-#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
+#else
+# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
+#endif
#if __has_attribute(require_constant_initialization)
# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__))
@@ -1295,12 +1296,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
#endif
-#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
-# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
-# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
-# endif
-#endif
-
#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
# define _LIBCPP_DIAGNOSE_WARNING(...) \
__attribute__((diagnose_if(__VA_ARGS__, "warning")))
@@ -1328,14 +1323,17 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_NODEBUG
#endif
-#ifndef _LIBCPP_NODEBUG_TYPE
-#if __has_attribute(__nodebug__) && \
- (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
-#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
+#if __has_attribute(__nodebug__) && (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900)
+# define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
#else
-#define _LIBCPP_NODEBUG_TYPE
+# define _LIBCPP_NODEBUG_TYPE
+#endif
+
+#if __has_attribute(__standalone_debug__)
+#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
+#else
+#define _LIBCPP_STANDALONE_DEBUG
#endif
-#endif // !defined(_LIBCPP_NODEBUG_TYPE)
#if __has_attribute(__preferred_name__)
#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
@@ -1352,11 +1350,19 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
-#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
+#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
+#define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
+#define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
+#define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
+#define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
+#endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
+
#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
#endif
@@ -1405,7 +1411,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#ifndef _LIBCPP_NO_AUTO_LINK
# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
-# if defined(_DLL)
+# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# pragma comment(lib, "c++.lib")
# else
# pragma comment(lib, "libc++.lib")
@@ -1413,8 +1419,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
#endif // _LIBCPP_NO_AUTO_LINK
-#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
-
// Configures the fopen close-on-exec mode character, if any. This string will
// be appended to any mode string used by fstream for fopen/fdopen.
//
@@ -1445,6 +1449,13 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_INIT_PRIORITY_MAX
#endif
+#if defined(__GNUC__) || defined(__clang__)
+#define _LIBCPP_FORMAT_PRINTF(a, b) \
+ __attribute__((__format__(__printf__, a, b)))
+#else
+#define _LIBCPP_FORMAT_PRINTF(a, b)
+#endif
+
#endif // __cplusplus
#endif // _LIBCPP_CONFIG
diff --git a/contrib/llvm-project/libcxx/include/__debug b/contrib/llvm-project/libcxx/include/__debug
index 7b5bfb3f8378..771e4316320b 100644
--- a/contrib/llvm-project/libcxx/include/__debug
+++ b/contrib/llvm-project/libcxx/include/__debug
@@ -270,4 +270,4 @@ _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_DEBUG_H
+#endif // _LIBCPP_DEBUG_H
diff --git a/contrib/llvm-project/libcxx/include/__errc b/contrib/llvm-project/libcxx/include/__errc
index 1b5b43391815..eb0e5eed13cf 100644
--- a/contrib/llvm-project/libcxx/include/__errc
+++ b/contrib/llvm-project/libcxx/include/__errc
@@ -216,4 +216,4 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP___ERRC
+#endif // _LIBCPP___ERRC
diff --git a/contrib/llvm-project/libcxx/include/__format/format_error.h b/contrib/llvm-project/libcxx/include/__format/format_error.h
new file mode 100644
index 000000000000..f983d0ce4ac4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__format/format_error.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_ERROR_H
+#define _LIBCPP___FORMAT_FORMAT_ERROR_H
+
+#include <__config>
+#include <stdexcept>
+
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include <cstdlib>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s)
+ : runtime_error(__s) {}
+ _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
+ : runtime_error(__s) {}
+ virtual ~format_error() noexcept;
+};
+
+_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
+__throw_format_error(const char* __s) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw format_error(__s);
+#else
+ (void)__s;
+ _VSTD::abort();
+#endif
+}
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMAT_ERROR_H
diff --git a/contrib/llvm-project/libcxx/include/__format/format_parse_context.h b/contrib/llvm-project/libcxx/include/__format/format_parse_context.h
new file mode 100644
index 000000000000..db39c1b54830
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__format/format_parse_context.h
@@ -0,0 +1,113 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
+#define _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
+
+#include <__config>
+#include <__format/format_error.h>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+// TODO FMT Remove this once we require compilers with proper C++20 support.
+// If the compiler has no concepts support, the format header will be disabled.
+// Without concepts support enable_if needs to be used and that too much effort
+// to support compilers with partial C++20 support.
+#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && \
+ !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context {
+public:
+ using char_type = _CharT;
+ using const_iterator = typename basic_string_view<_CharT>::const_iterator;
+ using iterator = const_iterator;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit basic_format_parse_context(basic_string_view<_CharT> __fmt,
+ size_t __num_args = 0) noexcept
+ : __begin_(__fmt.begin()),
+ __end_(__fmt.end()),
+ __indexing_(__unknown),
+ __next_arg_id_(0),
+ __num_args_(__num_args) {}
+
+ basic_format_parse_context(const basic_format_parse_context&) = delete;
+ basic_format_parse_context&
+ operator=(const basic_format_parse_context&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept {
+ return __begin_;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept {
+ return __end_;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(const_iterator __it) {
+ __begin_ = __it;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() {
+ if (__indexing_ == __manual)
+ __throw_format_error("Using automatic argument numbering in manual "
+ "argument numbering mode");
+
+ if (__indexing_ == __unknown)
+ __indexing_ = __automatic;
+ return __next_arg_id_++;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void check_arg_id(size_t __id) {
+ if (__indexing_ == __automatic)
+ __throw_format_error("Using manual argument numbering in automatic "
+ "argument numbering mode");
+
+ if (__indexing_ == __unknown)
+ __indexing_ = __manual;
+
+ // Throws an exception to make the expression a non core constant
+ // expression as required by:
+ // [format.parse.ctx]/11
+ // Remarks: Call expressions where id >= num_args_ are not core constant
+ // expressions ([expr.const]).
+ // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the
+ // behavior when id >= num_args_.
+ if (is_constant_evaluated() && __id >= __num_args_)
+ __throw_format_error("Argument index outside the valid range");
+ }
+
+private:
+ iterator __begin_;
+ iterator __end_;
+ enum _Indexing { __unknown, __manual, __automatic };
+ _Indexing __indexing_;
+ size_t __next_arg_id_;
+ size_t __num_args_;
+};
+
+using format_parse_context = basic_format_parse_context<char>;
+using wformat_parse_context = basic_format_parse_context<wchar_t>;
+
+#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
diff --git a/contrib/llvm-project/libcxx/include/__function_like.h b/contrib/llvm-project/libcxx/include/__function_like.h
new file mode 100644
index 000000000000..8a3597bacdcd
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__function_like.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_FUNCTION_LIKE_H
+#define _LIBCPP___ITERATOR_FUNCTION_LIKE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+// Per [range.iter.ops.general] and [algorithms.requirements], functions in namespace std::ranges
+// can't be found by ADL and inhibit ADL when found by unqualified lookup. The easiest way to
+// facilitate this is to use function objects.
+//
+// Since these are still standard library functions, we use `__function_like` to eliminate most of
+// the properties that function objects get by default (e.g. semiregularity, addressability), to
+// limit the surface area of the unintended public interface, so as to curb the effect of Hyrum's
+// law.
+struct __function_like {
+ __function_like() = delete;
+ __function_like(__function_like const&) = delete;
+ __function_like& operator=(__function_like const&) = delete;
+
+ void operator&() const = delete;
+
+ struct __tag { };
+
+protected:
+ constexpr explicit __function_like(__tag) noexcept {}
+ ~__function_like() = default;
+};
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_FUNCTION_LIKE_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/binary_function.h b/contrib/llvm-project/libcxx/include/__functional/binary_function.h
new file mode 100644
index 000000000000..8ca7b06662ae
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/binary_function.h
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Arg1, class _Arg2, class _Result>
+struct _LIBCPP_TEMPLATE_VIS binary_function
+{
+ typedef _Arg1 first_argument_type;
+ typedef _Arg2 second_argument_type;
+ typedef _Result result_type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/binary_negate.h b/contrib/llvm-project/libcxx/include/__functional/binary_negate.h
new file mode 100644
index 000000000000..4fc3f1ba2875
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/binary_negate.h
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H
+#define _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+template <class _Predicate>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
+ : public binary_function<typename _Predicate::first_argument_type,
+ typename _Predicate::second_argument_type,
+ bool>
+{
+ _Predicate __pred_;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
+ binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
+
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const typename _Predicate::first_argument_type& __x,
+ const typename _Predicate::second_argument_type& __y) const
+ {return !__pred_(__x, __y);}
+};
+
+template <class _Predicate>
+_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+binary_negate<_Predicate>
+not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
+
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/bind.h b/contrib/llvm-project/libcxx/include/__functional/bind.h
new file mode 100644
index 000000000000..79dfad723c68
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/bind.h
@@ -0,0 +1,386 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BIND_H
+#define _LIBCPP___FUNCTIONAL_BIND_H
+
+#include <__config>
+#include <__functional/weak_result_type.h>
+#include <__functional/invoke.h>
+#include <cstddef>
+#include <tuple>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp> struct __is_bind_expression : public false_type {};
+template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
+ : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
+#endif
+
+template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
+template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
+ : public __is_placeholder<typename remove_cv<_Tp>::type> {};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
+#endif
+
+namespace placeholders
+{
+
+template <int _Np> struct __ph {};
+
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
+_LIBCPP_FUNC_VIS extern const __ph<1> _1;
+_LIBCPP_FUNC_VIS extern const __ph<2> _2;
+_LIBCPP_FUNC_VIS extern const __ph<3> _3;
+_LIBCPP_FUNC_VIS extern const __ph<4> _4;
+_LIBCPP_FUNC_VIS extern const __ph<5> _5;
+_LIBCPP_FUNC_VIS extern const __ph<6> _6;
+_LIBCPP_FUNC_VIS extern const __ph<7> _7;
+_LIBCPP_FUNC_VIS extern const __ph<8> _8;
+_LIBCPP_FUNC_VIS extern const __ph<9> _9;
+_LIBCPP_FUNC_VIS extern const __ph<10> _10;
+#else
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{};
+/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{};
+#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
+
+} // placeholders
+
+template<int _Np>
+struct __is_placeholder<placeholders::__ph<_Np> >
+ : public integral_constant<int, _Np> {};
+
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Uj>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp&
+__mu(reference_wrapper<_Tp> __t, _Uj&)
+{
+ return __t.get();
+}
+
+template <class _Ti, class ..._Uj, size_t ..._Indx>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __invoke_of<_Ti&, _Uj...>::type
+__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
+{
+ return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
+}
+
+template <class _Ti, class ..._Uj>
+inline _LIBCPP_INLINE_VISIBILITY
+typename _EnableIf
+<
+ is_bind_expression<_Ti>::value,
+ __invoke_of<_Ti&, _Uj...>
+>::type
+__mu(_Ti& __ti, tuple<_Uj...>& __uj)
+{
+ typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
+ return _VSTD::__mu_expand(__ti, __uj, __indices());
+}
+
+template <bool IsPh, class _Ti, class _Uj>
+struct __mu_return2 {};
+
+template <class _Ti, class _Uj>
+struct __mu_return2<true, _Ti, _Uj>
+{
+ typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
+};
+
+template <class _Ti, class _Uj>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ 0 < is_placeholder<_Ti>::value,
+ typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
+>::type
+__mu(_Ti&, _Uj& __uj)
+{
+ const size_t _Indx = is_placeholder<_Ti>::value - 1;
+ return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
+}
+
+template <class _Ti, class _Uj>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+ !is_bind_expression<_Ti>::value &&
+ is_placeholder<_Ti>::value == 0 &&
+ !__is_reference_wrapper<_Ti>::value,
+ _Ti&
+>::type
+__mu(_Ti& __ti, _Uj&)
+{
+ return __ti;
+}
+
+template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
+ class _TupleUj>
+struct __mu_return_impl;
+
+template <bool _Invokable, class _Ti, class ..._Uj>
+struct __mu_return_invokable // false
+{
+ typedef __nat type;
+};
+
+template <class _Ti, class ..._Uj>
+struct __mu_return_invokable<true, _Ti, _Uj...>
+{
+ typedef typename __invoke_of<_Ti&, _Uj...>::type type;
+};
+
+template <class _Ti, class ..._Uj>
+struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
+ : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
+{
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return_impl<_Ti, false, false, true, _TupleUj>
+{
+ typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
+ _TupleUj>::type&& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return_impl<_Ti, true, false, false, _TupleUj>
+{
+ typedef typename _Ti::type& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return_impl<_Ti, false, false, false, _TupleUj>
+{
+ typedef _Ti& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return
+ : public __mu_return_impl<_Ti,
+ __is_reference_wrapper<_Ti>::value,
+ is_bind_expression<_Ti>::value,
+ 0 < is_placeholder<_Ti>::value &&
+ is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
+ _TupleUj>
+{
+};
+
+template <class _Fp, class _BoundArgs, class _TupleUj>
+struct __is_valid_bind_return
+{
+ static const bool value = false;
+};
+
+template <class _Fp, class ..._BoundArgs, class _TupleUj>
+struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
+{
+ static const bool value = __invokable<_Fp,
+ typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
+};
+
+template <class _Fp, class ..._BoundArgs, class _TupleUj>
+struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
+{
+ static const bool value = __invokable<_Fp,
+ typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
+};
+
+template <class _Fp, class _BoundArgs, class _TupleUj,
+ bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
+struct __bind_return;
+
+template <class _Fp, class ..._BoundArgs, class _TupleUj>
+struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
+{
+ typedef typename __invoke_of
+ <
+ _Fp&,
+ typename __mu_return
+ <
+ _BoundArgs,
+ _TupleUj
+ >::type...
+ >::type type;
+};
+
+template <class _Fp, class ..._BoundArgs, class _TupleUj>
+struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
+{
+ typedef typename __invoke_of
+ <
+ _Fp&,
+ typename __mu_return
+ <
+ const _BoundArgs,
+ _TupleUj
+ >::type...
+ >::type type;
+};
+
+template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __bind_return<_Fp, _BoundArgs, _Args>::type
+__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
+ _Args&& __args)
+{
+ return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...);
+}
+
+template<class _Fp, class ..._BoundArgs>
+class __bind
+#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public __weak_result_type<typename decay<_Fp>::type>
+#endif
+{
+protected:
+ typedef typename decay<_Fp>::type _Fd;
+ typedef tuple<typename decay<_BoundArgs>::type...> _Td;
+private:
+ _Fd __f_;
+ _Td __bound_args_;
+
+ typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
+public:
+ template <class _Gp, class ..._BA,
+ class = typename enable_if
+ <
+ is_constructible<_Fd, _Gp>::value &&
+ !is_same<typename remove_reference<_Gp>::type,
+ __bind>::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
+ : __f_(_VSTD::forward<_Gp>(__f)),
+ __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
+ operator()(_Args&& ...__args)
+ {
+ return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
+ tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
+ }
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
+ operator()(_Args&& ...__args) const
+ {
+ return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
+ tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
+ }
+};
+
+template<class _Fp, class ..._BoundArgs>
+struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
+
+template<class _Rp, class _Fp, class ..._BoundArgs>
+class __bind_r
+ : public __bind<_Fp, _BoundArgs...>
+{
+ typedef __bind<_Fp, _BoundArgs...> base;
+ typedef typename base::_Fd _Fd;
+ typedef typename base::_Td _Td;
+public:
+ typedef _Rp result_type;
+
+
+ template <class _Gp, class ..._BA,
+ class = typename enable_if
+ <
+ is_constructible<_Fd, _Gp>::value &&
+ !is_same<typename remove_reference<_Gp>::type,
+ __bind_r>::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
+ : base(_VSTD::forward<_Gp>(__f),
+ _VSTD::forward<_BA>(__bound_args)...) {}
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename enable_if
+ <
+ is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
+ result_type>::value || is_void<_Rp>::value,
+ result_type
+ >::type
+ operator()(_Args&& ...__args)
+ {
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
+ }
+
+ template <class ..._Args>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename enable_if
+ <
+ is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
+ result_type>::value || is_void<_Rp>::value,
+ result_type
+ >::type
+ operator()(_Args&& ...__args) const
+ {
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
+ }
+};
+
+template<class _Rp, class _Fp, class ..._BoundArgs>
+struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
+
+template<class _Fp, class ..._BoundArgs>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+__bind<_Fp, _BoundArgs...>
+bind(_Fp&& __f, _BoundArgs&&... __bound_args)
+{
+ typedef __bind<_Fp, _BoundArgs...> type;
+ return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
+}
+
+template<class _Rp, class _Fp, class ..._BoundArgs>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+__bind_r<_Rp, _Fp, _BoundArgs...>
+bind(_Fp&& __f, _BoundArgs&&... __bound_args)
+{
+ typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
+ return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BIND_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/bind_front.h b/contrib/llvm-project/libcxx/include/__functional/bind_front.h
new file mode 100644
index 000000000000..8690499f2b0c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/bind_front.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BIND_FRONT_H
+#define _LIBCPP___FUNCTIONAL_BIND_FRONT_H
+
+#include <__config>
+#include <__functional/perfect_forward.h>
+#include <__functional/invoke.h>
+#include <type_traits>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+struct __bind_front_op
+{
+ template<class... _Args>
+ constexpr static auto __call(_Args&&... __args)
+ noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
+ -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...))
+ { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); }
+};
+
+template<class _Fn, class... _Args,
+ class = _EnableIf<conjunction<is_constructible<decay_t<_Fn>, _Fn>,
+ is_move_constructible<decay_t<_Fn>>,
+ is_constructible<decay_t<_Args>, _Args>...,
+ is_move_constructible<decay_t<_Args>>...
+ >::value>>
+constexpr auto bind_front(_Fn&& __f, _Args&&... __args)
+{
+ return __perfect_forward<__bind_front_op, _Fn, _Args...>(_VSTD::forward<_Fn>(__f),
+ _VSTD::forward<_Args>(__args)...);
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/binder1st.h b/contrib/llvm-project/libcxx/include/__functional/binder1st.h
new file mode 100644
index 000000000000..5dd8f5cf0155
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/binder1st.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BINDER1ST_H
+#define _LIBCPP___FUNCTIONAL_BINDER1ST_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class __Operation>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
+ : public unary_function<typename __Operation::second_argument_type,
+ typename __Operation::result_type>
+{
+protected:
+ __Operation op;
+ typename __Operation::first_argument_type value;
+public:
+ _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
+ const typename __Operation::first_argument_type __y)
+ : op(__x), value(__y) {}
+ _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+ (typename __Operation::second_argument_type& __x) const
+ {return op(value, __x);}
+ _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+ (const typename __Operation::second_argument_type& __x) const
+ {return op(value, __x);}
+};
+
+template <class __Operation, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+binder1st<__Operation>
+bind1st(const __Operation& __op, const _Tp& __x)
+ {return binder1st<__Operation>(__op, __x);}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINDER1ST_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/binder2nd.h b/contrib/llvm-project/libcxx/include/__functional/binder2nd.h
new file mode 100644
index 000000000000..3ed5f5bf4540
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/binder2nd.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_BINDER2ND_H
+#define _LIBCPP___FUNCTIONAL_BINDER2ND_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class __Operation>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
+ : public unary_function<typename __Operation::first_argument_type,
+ typename __Operation::result_type>
+{
+protected:
+ __Operation op;
+ typename __Operation::second_argument_type value;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
+ : op(__x), value(__y) {}
+ _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+ ( typename __Operation::first_argument_type& __x) const
+ {return op(__x, value);}
+ _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+ (const typename __Operation::first_argument_type& __x) const
+ {return op(__x, value);}
+};
+
+template <class __Operation, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+binder2nd<__Operation>
+bind2nd(const __Operation& __op, const _Tp& __x)
+ {return binder2nd<__Operation>(__op, __x);}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINDER2ND_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/default_searcher.h b/contrib/llvm-project/libcxx/include/__functional/default_searcher.h
new file mode 100644
index 000000000000..1acbc1883afc
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/default_searcher.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H
+#define _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H
+
+#include <__algorithm/search.h>
+#include <__config>
+#include <__functional/operations.h>
+#include <__iterator/iterator_traits.h>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+// default searcher
+template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
+class _LIBCPP_TEMPLATE_VIS default_searcher {
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ default_searcher(_ForwardIterator __f, _ForwardIterator __l,
+ _BinaryPredicate __p = _BinaryPredicate())
+ : __first_(__f), __last_(__l), __pred_(__p) {}
+
+ template <typename _ForwardIterator2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair<_ForwardIterator2, _ForwardIterator2>
+ operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
+ {
+ return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
+ typename iterator_traits<_ForwardIterator>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category());
+ }
+
+private:
+ _ForwardIterator __first_;
+ _ForwardIterator __last_;
+ _BinaryPredicate __pred_;
+ };
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H
diff --git a/contrib/llvm-project/libcxx/include/__functional_03 b/contrib/llvm-project/libcxx/include/__functional/function.h
index 9616480611dc..ba629e1d145e 100644
--- a/contrib/llvm-project/libcxx/include/__functional_03
+++ b/contrib/llvm-project/libcxx/include/__functional/function.h
@@ -7,15 +7,1229 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_FUNCTIONAL_03
-#define _LIBCPP_FUNCTIONAL_03
-
-// manual variadic expansion for <functional>
+#ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_FUNCTION_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
+#include <__functional/unary_function.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/shared_ptr.h>
+#include <exception>
+#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>
+#include <type_traits>
+#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// bad_function_call
+
+class _LIBCPP_EXCEPTION_ABI bad_function_call
+ : public exception
+{
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+ virtual ~bad_function_call() _NOEXCEPT;
+
+ virtual const char* what() const _NOEXCEPT;
+#endif
+};
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_bad_function_call()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_function_call();
+#else
+ _VSTD::abort();
+#endif
+}
+
+#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated)
+# define _LIBCPP_DEPRECATED_CXX03_FUNCTION \
+ __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
+#else
+# define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */
+#endif
+
+template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
+
+namespace __function
+{
+
+template<class _Rp>
+struct __maybe_derive_from_unary_function
+{
+};
+
+template<class _Rp, class _A1>
+struct __maybe_derive_from_unary_function<_Rp(_A1)>
+ : public unary_function<_A1, _Rp>
+{
+};
+
+template<class _Rp>
+struct __maybe_derive_from_binary_function
+{
+};
+
+template<class _Rp, class _A1, class _A2>
+struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
+ : public binary_function<_A1, _A2, _Rp>
+{
+};
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Fp const&) { return true; }
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Fp* __ptr) { return __ptr; }
+
+template <class _Ret, class _Class>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(function<_Fp> const& __f) { return !!__f; }
+
+#ifdef _LIBCPP_HAS_EXTENSION_BLOCKS
+template <class _Rp, class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+bool __not_null(_Rp (^__p)(_Args...)) { return __p; }
+#endif
+
+} // namespace __function
+
+#ifndef _LIBCPP_CXX03_LANG
+
+namespace __function {
+
+// __alloc_func holds a functor and an allocator.
+
+template <class _Fp, class _Ap, class _FB> class __alloc_func;
+template <class _Fp, class _FB>
+class __default_alloc_func;
+
+template <class _Fp, class _Ap, class _Rp, class... _ArgTypes>
+class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
+{
+ __compressed_pair<_Fp, _Ap> __f_;
+
+ public:
+ typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
+ typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const _Target& __target() const { return __f_.first(); }
+
+ // WIN32 APIs may define __allocator, so use __get_allocator instead.
+ _LIBCPP_INLINE_VISIBILITY
+ const _Alloc& __get_allocator() const { return __f_.second(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __alloc_func(_Target&& __f)
+ : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
+ _VSTD::forward_as_tuple())
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __alloc_func(const _Target& __f, const _Alloc& __a)
+ : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
+ _VSTD::forward_as_tuple(__a))
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __alloc_func(const _Target& __f, _Alloc&& __a)
+ : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
+ _VSTD::forward_as_tuple(_VSTD::move(__a)))
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __alloc_func(_Target&& __f, _Alloc&& __a)
+ : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
+ _VSTD::forward_as_tuple(_VSTD::move(__a)))
+ {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp operator()(_ArgTypes&&... __arg)
+ {
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_.first(),
+ _VSTD::forward<_ArgTypes>(__arg)...);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __alloc_func* __clone() const
+ {
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef
+ typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
+ _AA;
+ _AA __a(__f_.second());
+ typedef __allocator_destructor<_AA> _Dp;
+ unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a));
+ return __hold.release();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); }
+
+ static void __destroy_and_delete(__alloc_func* __f) {
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
+ _FunAlloc;
+ _FunAlloc __a(__f->__get_allocator());
+ __f->destroy();
+ __a.deallocate(__f, 1);
+ }
+};
+
+template <class _Fp, class _Rp, class... _ArgTypes>
+class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
+ _Fp __f_;
+
+public:
+ typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const _Target& __target() const { return __f_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __default_alloc_func(_Target&& __f) : __f_(_VSTD::move(__f)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp operator()(_ArgTypes&&... __arg) {
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __default_alloc_func* __clone() const {
+ __builtin_new_allocator::__holder_t __hold =
+ __builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
+ __default_alloc_func* __res =
+ ::new ((void*)__hold.get()) __default_alloc_func(__f_);
+ (void)__hold.release();
+ return __res;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void destroy() _NOEXCEPT { __f_.~_Target(); }
+
+ static void __destroy_and_delete(__default_alloc_func* __f) {
+ __f->destroy();
+ __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1);
+ }
+};
+
+// __base provides an abstract interface for copyable functors.
+
+template<class _Fp> class _LIBCPP_TEMPLATE_VIS __base;
+
+template<class _Rp, class ..._ArgTypes>
+class __base<_Rp(_ArgTypes...)>
+{
+ __base(const __base&);
+ __base& operator=(const __base&);
+public:
+ _LIBCPP_INLINE_VISIBILITY __base() {}
+ _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
+ virtual __base* __clone() const = 0;
+ virtual void __clone(__base*) const = 0;
+ virtual void destroy() _NOEXCEPT = 0;
+ virtual void destroy_deallocate() _NOEXCEPT = 0;
+ virtual _Rp operator()(_ArgTypes&& ...) = 0;
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(const type_info&) const _NOEXCEPT = 0;
+ virtual const std::type_info& target_type() const _NOEXCEPT = 0;
+#endif // _LIBCPP_NO_RTTI
+};
+
+// __func implements __base for a given functor type.
+
+template<class _FD, class _Alloc, class _FB> class __func;
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
+ : public __base<_Rp(_ArgTypes...)>
+{
+ __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __func(_Fp&& __f)
+ : __f_(_VSTD::move(__f)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __func(const _Fp& __f, const _Alloc& __a)
+ : __f_(__f, __a) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __func(const _Fp& __f, _Alloc&& __a)
+ : __f_(__f, _VSTD::move(__a)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __func(_Fp&& __f, _Alloc&& __a)
+ : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+
+ virtual __base<_Rp(_ArgTypes...)>* __clone() const;
+ virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
+ virtual void destroy() _NOEXCEPT;
+ virtual void destroy_deallocate() _NOEXCEPT;
+ virtual _Rp operator()(_ArgTypes&&... __arg);
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(const type_info&) const _NOEXCEPT;
+ virtual const std::type_info& target_type() const _NOEXCEPT;
+#endif // _LIBCPP_NO_RTTI
+};
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+__base<_Rp(_ArgTypes...)>*
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.__get_allocator());
+ typedef __allocator_destructor<_Ap> _Dp;
+ unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+ ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a));
+ return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
+{
+ ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
+{
+ __f_.destroy();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
+{
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
+ _Ap __a(__f_.__get_allocator());
+ __f_.destroy();
+ __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+_Rp
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
+{
+ return __f_(_VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+const void*
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
+{
+ if (__ti == typeid(_Fp))
+ return &__f_.__target();
+ return nullptr;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
+{
+ return typeid(_Fp);
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+// __value_func creates a value-type from a __func.
+
+template <class _Fp> class __value_func;
+
+template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
+{
+ typename aligned_storage<3 * sizeof(void*)>::type __buf_;
+
+ typedef __base<_Rp(_ArgTypes...)> __func;
+ __func* __f_;
+
+ _LIBCPP_NO_CFI static __func* __as_base(void* p)
+ {
+ return reinterpret_cast<__func*>(p);
+ }
+
+ public:
+ _LIBCPP_INLINE_VISIBILITY
+ __value_func() _NOEXCEPT : __f_(nullptr) {}
+
+ template <class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a)
+ : __f_(nullptr)
+ {
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
+ typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
+ _FunAlloc;
+
+ if (__function::__not_null(__f))
+ {
+ _FunAlloc __af(__a);
+ if (sizeof(_Fun) <= sizeof(__buf_) &&
+ is_nothrow_copy_constructible<_Fp>::value &&
+ is_nothrow_copy_constructible<_FunAlloc>::value)
+ {
+ __f_ =
+ ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af));
+ }
+ else
+ {
+ typedef __allocator_destructor<_FunAlloc> _Dp;
+ unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));
+ ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f), _Alloc(__a));
+ __f_ = __hold.release();
+ }
+ }
+ }
+
+ template <class _Fp,
+ class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f)
+ : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ __value_func(const __value_func& __f)
+ {
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if ((void*)__f.__f_ == &__f.__buf_)
+ {
+ __f_ = __as_base(&__buf_);
+ __f.__f_->__clone(__f_);
+ }
+ else
+ __f_ = __f.__f_->__clone();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __value_func(__value_func&& __f) _NOEXCEPT
+ {
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if ((void*)__f.__f_ == &__f.__buf_)
+ {
+ __f_ = __as_base(&__buf_);
+ __f.__f_->__clone(__f_);
+ }
+ else
+ {
+ __f_ = __f.__f_;
+ __f.__f_ = nullptr;
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__value_func()
+ {
+ if ((void*)__f_ == &__buf_)
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __value_func& operator=(__value_func&& __f)
+ {
+ *this = nullptr;
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if ((void*)__f.__f_ == &__f.__buf_)
+ {
+ __f_ = __as_base(&__buf_);
+ __f.__f_->__clone(__f_);
+ }
+ else
+ {
+ __f_ = __f.__f_;
+ __f.__f_ = nullptr;
+ }
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __value_func& operator=(nullptr_t)
+ {
+ __func* __f = __f_;
+ __f_ = nullptr;
+ if ((void*)__f == &__buf_)
+ __f->destroy();
+ else if (__f)
+ __f->destroy_deallocate();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp operator()(_ArgTypes&&... __args) const
+ {
+ if (__f_ == nullptr)
+ __throw_bad_function_call();
+ return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__value_func& __f) _NOEXCEPT
+ {
+ if (&__f == this)
+ return;
+ if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)
+ {
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ __func* __t = __as_base(&__tempbuf);
+ __f_->__clone(__t);
+ __f_->destroy();
+ __f_ = nullptr;
+ __f.__f_->__clone(__as_base(&__buf_));
+ __f.__f_->destroy();
+ __f.__f_ = nullptr;
+ __f_ = __as_base(&__buf_);
+ __t->__clone(__as_base(&__f.__buf_));
+ __t->destroy();
+ __f.__f_ = __as_base(&__f.__buf_);
+ }
+ else if ((void*)__f_ == &__buf_)
+ {
+ __f_->__clone(__as_base(&__f.__buf_));
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = __as_base(&__f.__buf_);
+ }
+ else if ((void*)__f.__f_ == &__f.__buf_)
+ {
+ __f.__f_->__clone(__as_base(&__buf_));
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = __as_base(&__buf_);
+ }
+ else
+ _VSTD::swap(__f_, __f.__f_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; }
+
+#ifndef _LIBCPP_NO_RTTI
+ _LIBCPP_INLINE_VISIBILITY
+ const std::type_info& target_type() const _NOEXCEPT
+ {
+ if (__f_ == nullptr)
+ return typeid(void);
+ return __f_->target_type();
+ }
+
+ template <typename _Tp>
+ _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT
+ {
+ if (__f_ == nullptr)
+ return nullptr;
+ return (const _Tp*)__f_->target(typeid(_Tp));
+ }
+#endif // _LIBCPP_NO_RTTI
+};
+
+// Storage for a functor object, to be used with __policy to manage copy and
+// destruction.
+union __policy_storage
+{
+ mutable char __small[sizeof(void*) * 2];
+ void* __large;
+};
+
+// True if _Fun can safely be held in __policy_storage.__small.
+template <typename _Fun>
+struct __use_small_storage
+ : public integral_constant<
+ bool, sizeof(_Fun) <= sizeof(__policy_storage) &&
+ _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) &&
+ is_trivially_copy_constructible<_Fun>::value &&
+ is_trivially_destructible<_Fun>::value> {};
+
+// Policy contains information about how to copy, destroy, and move the
+// underlying functor. You can think of it as a vtable of sorts.
+struct __policy
+{
+ // Used to copy or destroy __large values. null for trivial objects.
+ void* (*const __clone)(const void*);
+ void (*const __destroy)(void*);
+
+ // True if this is the null policy (no value).
+ const bool __is_null;
+
+ // The target type. May be null if RTTI is disabled.
+ const std::type_info* const __type_info;
+
+ // Returns a pointer to a static policy object suitable for the functor
+ // type.
+ template <typename _Fun>
+ _LIBCPP_INLINE_VISIBILITY static const __policy* __create()
+ {
+ return __choose_policy<_Fun>(__use_small_storage<_Fun>());
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ static const __policy* __create_empty()
+ {
+ static const _LIBCPP_CONSTEXPR __policy __policy_ = {nullptr, nullptr,
+ true,
+#ifndef _LIBCPP_NO_RTTI
+ &typeid(void)
+#else
+ nullptr
+#endif
+ };
+ return &__policy_;
+ }
+
+ private:
+ template <typename _Fun> static void* __large_clone(const void* __s)
+ {
+ const _Fun* __f = static_cast<const _Fun*>(__s);
+ return __f->__clone();
+ }
+
+ template <typename _Fun>
+ static void __large_destroy(void* __s) {
+ _Fun::__destroy_and_delete(static_cast<_Fun*>(__s));
+ }
+
+ template <typename _Fun>
+ _LIBCPP_INLINE_VISIBILITY static const __policy*
+ __choose_policy(/* is_small = */ false_type) {
+ static const _LIBCPP_CONSTEXPR __policy __policy_ = {
+ &__large_clone<_Fun>, &__large_destroy<_Fun>, false,
+#ifndef _LIBCPP_NO_RTTI
+ &typeid(typename _Fun::_Target)
+#else
+ nullptr
+#endif
+ };
+ return &__policy_;
+ }
+
+ template <typename _Fun>
+ _LIBCPP_INLINE_VISIBILITY static const __policy*
+ __choose_policy(/* is_small = */ true_type)
+ {
+ static const _LIBCPP_CONSTEXPR __policy __policy_ = {
+ nullptr, nullptr, false,
+#ifndef _LIBCPP_NO_RTTI
+ &typeid(typename _Fun::_Target)
+#else
+ nullptr
+#endif
+ };
+ return &__policy_;
+ }
+};
+
+// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is
+// faster for types that can be passed in registers.
+template <typename _Tp>
+using __fast_forward =
+ typename conditional<is_scalar<_Tp>::value, _Tp, _Tp&&>::type;
+
+// __policy_invoker calls an instance of __alloc_func held in __policy_storage.
+
+template <class _Fp> struct __policy_invoker;
+
+template <class _Rp, class... _ArgTypes>
+struct __policy_invoker<_Rp(_ArgTypes...)>
+{
+ typedef _Rp (*__Call)(const __policy_storage*,
+ __fast_forward<_ArgTypes>...);
+
+ __Call __call_;
+
+ // Creates an invoker that throws bad_function_call.
+ _LIBCPP_INLINE_VISIBILITY
+ __policy_invoker() : __call_(&__call_empty) {}
+
+ // Creates an invoker that calls the given instance of __func.
+ template <typename _Fun>
+ _LIBCPP_INLINE_VISIBILITY static __policy_invoker __create()
+ {
+ return __policy_invoker(&__call_impl<_Fun>);
+ }
+
+ private:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __policy_invoker(__Call __c) : __call_(__c) {}
+
+ static _Rp __call_empty(const __policy_storage*,
+ __fast_forward<_ArgTypes>...)
+ {
+ __throw_bad_function_call();
+ }
+
+ template <typename _Fun>
+ static _Rp __call_impl(const __policy_storage* __buf,
+ __fast_forward<_ArgTypes>... __args)
+ {
+ _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value
+ ? &__buf->__small
+ : __buf->__large);
+ return (*__f)(_VSTD::forward<_ArgTypes>(__args)...);
+ }
+};
+
+// __policy_func uses a __policy and __policy_invoker to create a type-erased,
+// copyable functor.
+
+template <class _Fp> class __policy_func;
+
+template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
+{
+ // Inline storage for small objects.
+ __policy_storage __buf_;
+
+ // Calls the value stored in __buf_. This could technically be part of
+ // policy, but storing it here eliminates a level of indirection inside
+ // operator().
+ typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker;
+ __invoker __invoker_;
+
+ // The policy that describes how to move / copy / destroy __buf_. Never
+ // null, even if the function is empty.
+ const __policy* __policy_;
+
+ public:
+ _LIBCPP_INLINE_VISIBILITY
+ __policy_func() : __policy_(__policy::__create_empty()) {}
+
+ template <class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY __policy_func(_Fp&& __f, const _Alloc& __a)
+ : __policy_(__policy::__create_empty())
+ {
+ typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
+ _FunAlloc;
+
+ if (__function::__not_null(__f))
+ {
+ __invoker_ = __invoker::template __create<_Fun>();
+ __policy_ = __policy::__create<_Fun>();
+
+ _FunAlloc __af(__a);
+ if (__use_small_storage<_Fun>())
+ {
+ ::new ((void*)&__buf_.__small)
+ _Fun(_VSTD::move(__f), _Alloc(__af));
+ }
+ else
+ {
+ typedef __allocator_destructor<_FunAlloc> _Dp;
+ unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));
+ ::new ((void*)__hold.get())
+ _Fun(_VSTD::move(__f), _Alloc(__af));
+ __buf_.__large = __hold.release();
+ }
+ }
+ }
+
+ template <class _Fp, class = typename enable_if<!is_same<typename decay<_Fp>::type, __policy_func>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY explicit __policy_func(_Fp&& __f)
+ : __policy_(__policy::__create_empty()) {
+ typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun;
+
+ if (__function::__not_null(__f)) {
+ __invoker_ = __invoker::template __create<_Fun>();
+ __policy_ = __policy::__create<_Fun>();
+ if (__use_small_storage<_Fun>()) {
+ ::new ((void*)&__buf_.__small) _Fun(_VSTD::move(__f));
+ } else {
+ __builtin_new_allocator::__holder_t __hold =
+ __builtin_new_allocator::__allocate_type<_Fun>(1);
+ __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f));
+ (void)__hold.release();
+ }
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __policy_func(const __policy_func& __f)
+ : __buf_(__f.__buf_), __invoker_(__f.__invoker_),
+ __policy_(__f.__policy_)
+ {
+ if (__policy_->__clone)
+ __buf_.__large = __policy_->__clone(__f.__buf_.__large);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __policy_func(__policy_func&& __f)
+ : __buf_(__f.__buf_), __invoker_(__f.__invoker_),
+ __policy_(__f.__policy_)
+ {
+ if (__policy_->__destroy)
+ {
+ __f.__policy_ = __policy::__create_empty();
+ __f.__invoker_ = __invoker();
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~__policy_func()
+ {
+ if (__policy_->__destroy)
+ __policy_->__destroy(__buf_.__large);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __policy_func& operator=(__policy_func&& __f)
+ {
+ *this = nullptr;
+ __buf_ = __f.__buf_;
+ __invoker_ = __f.__invoker_;
+ __policy_ = __f.__policy_;
+ __f.__policy_ = __policy::__create_empty();
+ __f.__invoker_ = __invoker();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __policy_func& operator=(nullptr_t)
+ {
+ const __policy* __p = __policy_;
+ __policy_ = __policy::__create_empty();
+ __invoker_ = __invoker();
+ if (__p->__destroy)
+ __p->__destroy(__buf_.__large);
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp operator()(_ArgTypes&&... __args) const
+ {
+ return __invoker_.__call_(_VSTD::addressof(__buf_),
+ _VSTD::forward<_ArgTypes>(__args)...);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__policy_func& __f)
+ {
+ _VSTD::swap(__invoker_, __f.__invoker_);
+ _VSTD::swap(__policy_, __f.__policy_);
+ _VSTD::swap(__buf_, __f.__buf_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT
+ {
+ return !__policy_->__is_null;
+ }
+
+#ifndef _LIBCPP_NO_RTTI
+ _LIBCPP_INLINE_VISIBILITY
+ const std::type_info& target_type() const _NOEXCEPT
+ {
+ return *__policy_->__type_info;
+ }
+
+ template <typename _Tp>
+ _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT
+ {
+ if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info)
+ return nullptr;
+ if (__policy_->__clone) // Out of line storage.
+ return reinterpret_cast<const _Tp*>(__buf_.__large);
+ else
+ return reinterpret_cast<const _Tp*>(&__buf_.__small);
+ }
+#endif // _LIBCPP_NO_RTTI
+};
+
+#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
+
+extern "C" void *_Block_copy(const void *);
+extern "C" void _Block_release(const void *);
+
+template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
+class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
+ : public __base<_Rp(_ArgTypes...)>
+{
+ typedef _Rp1(^__block_type)(_ArgTypes1...);
+ __block_type __f_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __func(__block_type const& __f)
+ : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
+ { }
+
+ // [TODO] add && to save on a retain
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __func(__block_type __f, const _Alloc& /* unused */)
+ : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
+ { }
+
+ virtual __base<_Rp(_ArgTypes...)>* __clone() const {
+ _LIBCPP_ASSERT(false,
+ "Block pointers are just pointers, so they should always fit into "
+ "std::function's small buffer optimization. This function should "
+ "never be invoked.");
+ return nullptr;
+ }
+
+ virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
+ ::new ((void*)__p) __func(__f_);
+ }
+
+ virtual void destroy() _NOEXCEPT {
+ if (__f_)
+ _Block_release(__f_);
+ __f_ = 0;
+ }
+
+ virtual void destroy_deallocate() _NOEXCEPT {
+ _LIBCPP_ASSERT(false,
+ "Block pointers are just pointers, so they should always fit into "
+ "std::function's small buffer optimization. This function should "
+ "never be invoked.");
+ }
+
+ virtual _Rp operator()(_ArgTypes&& ... __arg) {
+ return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
+ }
+
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* target(type_info const& __ti) const _NOEXCEPT {
+ if (__ti == typeid(__func::__block_type))
+ return &__f_;
+ return (const void*)nullptr;
+ }
+
+ virtual const std::type_info& target_type() const _NOEXCEPT {
+ return typeid(__func::__block_type);
+ }
+#endif // _LIBCPP_NO_RTTI
+};
+
+#endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC
+
+} // __function
+
+template<class _Rp, class ..._ArgTypes>
+class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
+#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
+ public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
+#endif
+{
+#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
+ typedef __function::__value_func<_Rp(_ArgTypes...)> __func;
+#else
+ typedef __function::__policy_func<_Rp(_ArgTypes...)> __func;
+#endif
+
+ __func __f_;
+
+ template <class _Fp, bool = _And<
+ _IsNotSame<__uncvref_t<_Fp>, function>,
+ __invokable<_Fp, _ArgTypes...>
+ >::value>
+ struct __callable;
+ template <class _Fp>
+ struct __callable<_Fp, true>
+ {
+ static const bool value = is_void<_Rp>::value ||
+ __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type,
+ _Rp>::value;
+ };
+ template <class _Fp>
+ struct __callable<_Fp, false>
+ {
+ static const bool value = false;
+ };
+
+ template <class _Fp>
+ using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type;
+public:
+ typedef _Rp result_type;
+
+ // construct/copy/destroy:
+ _LIBCPP_INLINE_VISIBILITY
+ function() _NOEXCEPT { }
+ _LIBCPP_INLINE_VISIBILITY
+ function(nullptr_t) _NOEXCEPT {}
+ function(const function&);
+ function(function&&) _NOEXCEPT;
+ template<class _Fp, class = _EnableIfLValueCallable<_Fp>>
+ function(_Fp);
+
+#if _LIBCPP_STD_VER <= 14
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
+ template<class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {}
+ template<class _Alloc>
+ function(allocator_arg_t, const _Alloc&, const function&);
+ template<class _Alloc>
+ function(allocator_arg_t, const _Alloc&, function&&);
+ template<class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>>
+ function(allocator_arg_t, const _Alloc& __a, _Fp __f);
+#endif
+
+ function& operator=(const function&);
+ function& operator=(function&&) _NOEXCEPT;
+ function& operator=(nullptr_t) _NOEXCEPT;
+ template<class _Fp, class = _EnableIfLValueCallable<typename decay<_Fp>::type>>
+ function& operator=(_Fp&&);
+
+ ~function();
+
+ // function modifiers:
+ void swap(function&) _NOEXCEPT;
+
+#if _LIBCPP_STD_VER <= 14
+ template<class _Fp, class _Alloc>
+ _LIBCPP_INLINE_VISIBILITY
+ void assign(_Fp&& __f, const _Alloc& __a)
+ {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
+#endif
+
+ // function capacity:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {
+ return static_cast<bool>(__f_);
+ }
+
+ // deleted overloads close possible hole in the type system
+ template<class _R2, class... _ArgTypes2>
+ bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
+ template<class _R2, class... _ArgTypes2>
+ bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
+public:
+ // function invocation:
+ _Rp operator()(_ArgTypes...) const;
+
+#ifndef _LIBCPP_NO_RTTI
+ // function target access:
+ const std::type_info& target_type() const _NOEXCEPT;
+ template <typename _Tp> _Tp* target() _NOEXCEPT;
+ template <typename _Tp> const _Tp* target() const _NOEXCEPT;
+#endif // _LIBCPP_NO_RTTI
+};
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _Rp, class ..._Ap>
+function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>;
+
+template<class _Fp>
+struct __strip_signature;
+
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); };
+
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); };
+
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); };
+
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); };
+template<class _Rp, class _Gp, class ..._Ap>
+struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); };
+
+template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
+function(_Fp) -> function<_Stripped>;
+#endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {}
+
+#if _LIBCPP_STD_VER <= 14
+template<class _Rp, class ..._ArgTypes>
+template <class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
+ const function& __f) : __f_(__f.__f_) {}
+#endif
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
+ : __f_(_VSTD::move(__f.__f_)) {}
+
+#if _LIBCPP_STD_VER <= 14
+template<class _Rp, class ..._ArgTypes>
+template <class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
+ function&& __f)
+ : __f_(_VSTD::move(__f.__f_)) {}
+#endif
+
+template <class _Rp, class... _ArgTypes>
+template <class _Fp, class>
+function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(_VSTD::move(__f)) {}
+
+#if _LIBCPP_STD_VER <= 14
+template <class _Rp, class... _ArgTypes>
+template <class _Fp, class _Alloc, class>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a,
+ _Fp __f)
+ : __f_(_VSTD::move(__f), __a) {}
+#endif
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(const function& __f)
+{
+ function(__f).swap(*this);
+ return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
+{
+ __f_ = _VSTD::move(__f.__f_);
+ return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
+{
+ __f_ = nullptr;
+ return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp, class>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
+{
+ function(_VSTD::forward<_Fp>(__f)).swap(*this);
+ return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>::~function() {}
+
+template<class _Rp, class ..._ArgTypes>
+void
+function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
+{
+ __f_.swap(__f.__f_);
+}
+
+template<class _Rp, class ..._ArgTypes>
+_Rp
+function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
+{
+ return __f_(_VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class ..._ArgTypes>
+const std::type_info&
+function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
+{
+ return __f_.target_type();
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <typename _Tp>
+_Tp*
+function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
+{
+ return (_Tp*)(__f_.template target<_Tp>());
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
+{
+ return __f_.template target<_Tp>();
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
+{return __x.swap(__y);}
+
+#else // _LIBCPP_CXX03_LANG
+
namespace __function {
template<class _Fp> class __base;
@@ -36,7 +1250,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp, class _A0>
@@ -55,7 +1269,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp, class _A0, class _A1>
@@ -74,7 +1288,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp, class _A0, class _A1, class _A2>
@@ -93,7 +1307,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _FD, class _Alloc, class _FB> class __func;
@@ -114,7 +1328,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Fp, class _Alloc, class _Rp>
@@ -181,7 +1395,7 @@ __func<_Fp, _Alloc, _Rp()>::target_type() const
return typeid(_Fp);
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template<class _Fp, class _Alloc, class _Rp, class _A0>
class __func<_Fp, _Alloc, _Rp(_A0)>
@@ -200,7 +1414,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Fp, class _Alloc, class _Rp, class _A0>
@@ -267,7 +1481,7 @@ __func<_Fp, _Alloc, _Rp(_A0)>::target_type() const
return typeid(_Fp);
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
@@ -286,7 +1500,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
@@ -353,7 +1567,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const
return typeid(_Fp);
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>
@@ -372,7 +1586,7 @@ public:
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
@@ -439,7 +1653,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
return typeid(_Fp);
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
} // __function
@@ -493,7 +1707,7 @@ public:
{function(allocator_arg, __a, __f).swap(*this);}
// 20.7.16.2.3, function capacity:
- _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
private:
// deleted overloads close possible hole in the type system
@@ -510,7 +1724,7 @@ public:
const std::type_info& target_type() const;
template <typename _Tp> _Tp* target();
template <typename _Tp> const _Tp* target() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp>
@@ -720,7 +1934,7 @@ function<_Rp()>::target() const
return (const _Tp*)__f_->target(typeid(_Tp));
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template<class _Rp, class _A0>
class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)>
@@ -773,7 +1987,7 @@ public:
{function(allocator_arg, __a, __f).swap(*this);}
// 20.7.16.2.3, function capacity:
- _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
private:
// deleted overloads close possible hole in the type system
@@ -790,7 +2004,7 @@ public:
const std::type_info& target_type() const;
template <typename _Tp> _Tp* target();
template <typename _Tp> const _Tp* target() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp, class _A0>
@@ -1000,7 +2214,7 @@ function<_Rp(_A0)>::target() const
return (const _Tp*)__f_->target(typeid(_Tp));
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template<class _Rp, class _A0, class _A1>
class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)>
@@ -1053,7 +2267,7 @@ public:
{function(allocator_arg, __a, __f).swap(*this);}
// 20.7.16.2.3, function capacity:
- operator bool() const {return __f_;}
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
private:
// deleted overloads close possible hole in the type system
@@ -1070,7 +2284,7 @@ public:
const std::type_info& target_type() const;
template <typename _Tp> _Tp* target();
template <typename _Tp> const _Tp* target() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp, class _A0, class _A1>
@@ -1280,7 +2494,7 @@ function<_Rp(_A0, _A1)>::target() const
return (const _Tp*)__f_->target(typeid(_Tp));
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template<class _Rp, class _A0, class _A1, class _A2>
class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)>
@@ -1332,7 +2546,7 @@ public:
{function(allocator_arg, __a, __f).swap(*this);}
// 20.7.16.2.3, function capacity:
- _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
private:
// deleted overloads close possible hole in the type system
@@ -1349,7 +2563,7 @@ public:
const std::type_info& target_type() const;
template <typename _Tp> _Tp* target();
template <typename _Tp> const _Tp* target() const;
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
};
template<class _Rp, class _A0, class _A1, class _A2>
@@ -1560,7 +2774,7 @@ function<_Rp(_A0, _A1, _A2)>::target() const
return (const _Tp*)__f_->target(typeid(_Tp));
}
-#endif // _LIBCPP_NO_RTTI
+#endif // _LIBCPP_NO_RTTI
template <class _Fp>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1588,4 +2802,8 @@ void
swap(function<_Fp>& __x, function<_Fp>& __y)
{return __x.swap(__y);}
-#endif // _LIBCPP_FUNCTIONAL_03
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/hash.h b/contrib/llvm-project/libcxx/include/__functional/hash.h
new file mode 100644
index 000000000000..ebcbbad13387
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/hash.h
@@ -0,0 +1,873 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_HASH_H
+#define _LIBCPP___FUNCTIONAL_HASH_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+#include <__tuple>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <__utility/swap.h>
+#include <cstdint>
+#include <cstring>
+#include <cstddef>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_Size
+__loadword(const void* __p)
+{
+ _Size __r;
+ _VSTD::memcpy(&__r, __p, sizeof(__r));
+ return __r;
+}
+
+// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
+// is 64 bits. This is because cityhash64 uses 64bit x 64bit
+// multiplication, which can be very slow on 32-bit systems.
+template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__>
+struct __murmur2_or_cityhash;
+
+template <class _Size>
+struct __murmur2_or_cityhash<_Size, 32>
+{
+ inline _Size operator()(const void* __key, _Size __len)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK;
+};
+
+// murmur2
+template <class _Size>
+_Size
+__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
+{
+ const _Size __m = 0x5bd1e995;
+ const _Size __r = 24;
+ _Size __h = __len;
+ const unsigned char* __data = static_cast<const unsigned char*>(__key);
+ for (; __len >= 4; __data += 4, __len -= 4)
+ {
+ _Size __k = __loadword<_Size>(__data);
+ __k *= __m;
+ __k ^= __k >> __r;
+ __k *= __m;
+ __h *= __m;
+ __h ^= __k;
+ }
+ switch (__len)
+ {
+ case 3:
+ __h ^= static_cast<_Size>(__data[2] << 16);
+ _LIBCPP_FALLTHROUGH();
+ case 2:
+ __h ^= static_cast<_Size>(__data[1] << 8);
+ _LIBCPP_FALLTHROUGH();
+ case 1:
+ __h ^= __data[0];
+ __h *= __m;
+ }
+ __h ^= __h >> 13;
+ __h *= __m;
+ __h ^= __h >> 15;
+ return __h;
+}
+
+template <class _Size>
+struct __murmur2_or_cityhash<_Size, 64>
+{
+ inline _Size operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK;
+
+ private:
+ // Some primes between 2^63 and 2^64.
+ static const _Size __k0 = 0xc3a5c85c97cb3127ULL;
+ static const _Size __k1 = 0xb492b66fbe98f273ULL;
+ static const _Size __k2 = 0x9ae16a3b2f90404fULL;
+ static const _Size __k3 = 0xc949d7c7509e6557ULL;
+
+ static _Size __rotate(_Size __val, int __shift) {
+ return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
+ }
+
+ static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
+ return (__val >> __shift) | (__val << (64 - __shift));
+ }
+
+ static _Size __shift_mix(_Size __val) {
+ return __val ^ (__val >> 47);
+ }
+
+ static _Size __hash_len_16(_Size __u, _Size __v)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+ {
+ const _Size __mul = 0x9ddfea08eb382d69ULL;
+ _Size __a = (__u ^ __v) * __mul;
+ __a ^= (__a >> 47);
+ _Size __b = (__v ^ __a) * __mul;
+ __b ^= (__b >> 47);
+ __b *= __mul;
+ return __b;
+ }
+
+ static _Size __hash_len_0_to_16(const char* __s, _Size __len)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+ {
+ if (__len > 8) {
+ const _Size __a = __loadword<_Size>(__s);
+ const _Size __b = __loadword<_Size>(__s + __len - 8);
+ return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
+ }
+ if (__len >= 4) {
+ const uint32_t __a = __loadword<uint32_t>(__s);
+ const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
+ return __hash_len_16(__len + (__a << 3), __b);
+ }
+ if (__len > 0) {
+ const unsigned char __a = static_cast<unsigned char>(__s[0]);
+ const unsigned char __b = static_cast<unsigned char>(__s[__len >> 1]);
+ const unsigned char __c = static_cast<unsigned char>(__s[__len - 1]);
+ const uint32_t __y = static_cast<uint32_t>(__a) +
+ (static_cast<uint32_t>(__b) << 8);
+ const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2);
+ return __shift_mix(__y * __k2 ^ __z * __k3) * __k2;
+ }
+ return __k2;
+ }
+
+ static _Size __hash_len_17_to_32(const char *__s, _Size __len)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+ {
+ const _Size __a = __loadword<_Size>(__s) * __k1;
+ const _Size __b = __loadword<_Size>(__s + 8);
+ const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
+ const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
+ return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
+ __a + __rotate(__b ^ __k3, 20) - __c + __len);
+ }
+
+ // Return a 16-byte hash for 48 bytes. Quick and dirty.
+ // Callers do best to use "random-looking" values for a and b.
+ static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
+ _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+ {
+ __a += __w;
+ __b = __rotate(__b + __a + __z, 21);
+ const _Size __c = __a;
+ __a += __x;
+ __a += __y;
+ __b += __rotate(__a, 44);
+ return pair<_Size, _Size>(__a + __z, __b + __c);
+ }
+
+ // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+ static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
+ const char* __s, _Size __a, _Size __b)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+ {
+ return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
+ __loadword<_Size>(__s + 8),
+ __loadword<_Size>(__s + 16),
+ __loadword<_Size>(__s + 24),
+ __a,
+ __b);
+ }
+
+ // Return an 8-byte hash for 33 to 64 bytes.
+ static _Size __hash_len_33_to_64(const char *__s, size_t __len)
+ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+ {
+ _Size __z = __loadword<_Size>(__s + 24);
+ _Size __a = __loadword<_Size>(__s) +
+ (__len + __loadword<_Size>(__s + __len - 16)) * __k0;
+ _Size __b = __rotate(__a + __z, 52);
+ _Size __c = __rotate(__a, 37);
+ __a += __loadword<_Size>(__s + 8);
+ __c += __rotate(__a, 7);
+ __a += __loadword<_Size>(__s + 16);
+ _Size __vf = __a + __z;
+ _Size __vs = __b + __rotate(__a, 31) + __c;
+ __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
+ __z += __loadword<_Size>(__s + __len - 8);
+ __b = __rotate(__a + __z, 52);
+ __c = __rotate(__a, 37);
+ __a += __loadword<_Size>(__s + __len - 24);
+ __c += __rotate(__a, 7);
+ __a += __loadword<_Size>(__s + __len - 16);
+ _Size __wf = __a + __z;
+ _Size __ws = __b + __rotate(__a, 31) + __c;
+ _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
+ return __shift_mix(__r * __k0 + __vs) * __k2;
+ }
+};
+
+// cityhash64
+template <class _Size>
+_Size
+__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
+{
+ const char* __s = static_cast<const char*>(__key);
+ if (__len <= 32) {
+ if (__len <= 16) {
+ return __hash_len_0_to_16(__s, __len);
+ } else {
+ return __hash_len_17_to_32(__s, __len);
+ }
+ } else if (__len <= 64) {
+ return __hash_len_33_to_64(__s, __len);
+ }
+
+ // For strings over 64 bytes we hash the end first, and then as we
+ // loop we keep 56 bytes of state: v, w, x, y, and z.
+ _Size __x = __loadword<_Size>(__s + __len - 40);
+ _Size __y = __loadword<_Size>(__s + __len - 16) +
+ __loadword<_Size>(__s + __len - 56);
+ _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
+ __loadword<_Size>(__s + __len - 24));
+ pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
+ pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
+ __x = __x * __k1 + __loadword<_Size>(__s);
+
+ // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
+ __len = (__len - 1) & ~static_cast<_Size>(63);
+ do {
+ __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
+ __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
+ __x ^= __w.second;
+ __y += __v.first + __loadword<_Size>(__s + 40);
+ __z = __rotate(__z + __w.first, 33) * __k1;
+ __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
+ __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
+ __y + __loadword<_Size>(__s + 16));
+ _VSTD::swap(__z, __x);
+ __s += 64;
+ __len -= 64;
+ } while (__len != 0);
+ return __hash_len_16(
+ __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z,
+ __hash_len_16(__v.second, __w.second) + __x);
+}
+
+template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
+struct __scalar_hash;
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct __scalar_hash<_Tp, 0>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp __v) const _NOEXCEPT
+ {
+ union
+ {
+ _Tp __t;
+ size_t __a;
+ } __u;
+ __u.__a = 0;
+ __u.__t = __v;
+ return __u.__a;
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct __scalar_hash<_Tp, 1>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp __v) const _NOEXCEPT
+ {
+ union
+ {
+ _Tp __t;
+ size_t __a;
+ } __u;
+ __u.__t = __v;
+ return __u.__a;
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct __scalar_hash<_Tp, 2>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp __v) const _NOEXCEPT
+ {
+ union
+ {
+ _Tp __t;
+ struct
+ {
+ size_t __a;
+ size_t __b;
+ } __s;
+ } __u;
+ __u.__t = __v;
+ return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct __scalar_hash<_Tp, 3>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp __v) const _NOEXCEPT
+ {
+ union
+ {
+ _Tp __t;
+ struct
+ {
+ size_t __a;
+ size_t __b;
+ size_t __c;
+ } __s;
+ } __u;
+ __u.__t = __v;
+ return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct __scalar_hash<_Tp, 4>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp __v) const _NOEXCEPT
+ {
+ union
+ {
+ _Tp __t;
+ struct
+ {
+ size_t __a;
+ size_t __b;
+ size_t __c;
+ size_t __d;
+ } __s;
+ } __u;
+ __u.__t = __v;
+ return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+ }
+};
+
+struct _PairT {
+ size_t first;
+ size_t second;
+};
+
+_LIBCPP_INLINE_VISIBILITY
+inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
+ typedef __scalar_hash<_PairT> _HashT;
+ const _PairT __p = {__lhs, __rhs};
+ return _HashT()(__p);
+}
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template<class _Tp>
+struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp*, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp* __v) const _NOEXCEPT
+ {
+ union
+ {
+ _Tp* __t;
+ size_t __a;
+ } __u;
+ __u.__t = __v;
+ return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+ }
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<bool>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<bool, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<char>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<char, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<signed char>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<signed char, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<unsigned char, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<char8_t, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+#endif // !_LIBCPP_HAS_NO_CHAR8_T
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<char16_t, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<char32_t, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<wchar_t, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<short>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<short, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<unsigned short, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<int>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<int, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<unsigned int, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<long>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<long, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<unsigned long, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<long long>
+ : public __scalar_hash<long long>
+{
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long>
+ : public __scalar_hash<unsigned long long>
+{
+};
+
+#ifndef _LIBCPP_HAS_NO_INT128
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<__int128_t>
+ : public __scalar_hash<__int128_t>
+{
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t>
+ : public __scalar_hash<__uint128_t>
+{
+};
+
+#endif
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<float>
+ : public __scalar_hash<float>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(float __v) const _NOEXCEPT
+ {
+ // -0.0 and 0.0 should return same hash
+ if (__v == 0.0f)
+ return 0;
+ return __scalar_hash<float>::operator()(__v);
+ }
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<double>
+ : public __scalar_hash<double>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(double __v) const _NOEXCEPT
+ {
+ // -0.0 and 0.0 should return same hash
+ if (__v == 0.0)
+ return 0;
+ return __scalar_hash<double>::operator()(__v);
+ }
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<long double>
+ : public __scalar_hash<long double>
+{
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(long double __v) const _NOEXCEPT
+ {
+ // -0.0 and 0.0 should return same hash
+ if (__v == 0.0L)
+ return 0;
+#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__))
+ // Zero out padding bits
+ union
+ {
+ long double __t;
+ struct
+ {
+ size_t __a;
+ size_t __b;
+ size_t __c;
+ size_t __d;
+ } __s;
+ } __u;
+ __u.__s.__a = 0;
+ __u.__s.__b = 0;
+ __u.__s.__c = 0;
+ __u.__s.__d = 0;
+ __u.__t = __v;
+ return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
+#elif defined(__x86_64__)
+ // Zero out padding bits
+ union
+ {
+ long double __t;
+ struct
+ {
+ size_t __a;
+ size_t __b;
+ } __s;
+ } __u;
+ __u.__s.__a = 0;
+ __u.__s.__b = 0;
+ __u.__t = __v;
+ return __u.__s.__a ^ __u.__s.__b;
+#else
+ return __scalar_hash<long double>::operator()(__v);
+#endif
+ }
+};
+
+#if _LIBCPP_STD_VER > 11
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp, bool = is_enum<_Tp>::value>
+struct _LIBCPP_TEMPLATE_VIS __enum_hash
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<_Tp, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(_Tp __v) const _NOEXCEPT
+ {
+ typedef typename underlying_type<_Tp>::type type;
+ return hash<type>{}(static_cast<type>(__v));
+ }
+};
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
+ __enum_hash() = delete;
+ __enum_hash(__enum_hash const&) = delete;
+ __enum_hash& operator=(__enum_hash const&) = delete;
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
+{
+};
+#endif
+
+#if _LIBCPP_STD_VER > 14
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public unary_function<nullptr_t, size_t>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(nullptr_t) const _NOEXCEPT {
+ return 662607004ull;
+ }
+};
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Key, class _Hash>
+using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
+ is_copy_constructible<_Hash>::value &&
+ is_move_constructible<_Hash>::value &&
+ __invokable_r<size_t, _Hash, _Key const&>::value
+>;
+
+template <class _Key, class _Hash = hash<_Key> >
+using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
+ __check_hash_requirements<_Key, _Hash>::value &&
+ is_default_constructible<_Hash>::value
+>;
+
+#if _LIBCPP_STD_VER > 14
+template <class _Type, class>
+using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type;
+
+template <class _Type, class ..._Keys>
+using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type,
+ typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type
+>;
+#else
+template <class _Type, class ...>
+using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type;
+#endif
+
+#endif // !_LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FUNCTIONAL_HASH_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/identity.h b/contrib/llvm-project/libcxx/include/__functional/identity.h
new file mode 100644
index 000000000000..6b8346b3b2a7
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/identity.h
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_IDENTITY_H
+#define _LIBCPP___FUNCTIONAL_IDENTITY_H
+
+#include <__config>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+struct identity {
+ template<class _Tp>
+ _LIBCPP_NODISCARD_EXT constexpr _Tp&& operator()(_Tp&& __t) const noexcept
+ {
+ return _VSTD::forward<_Tp>(__t);
+ }
+
+ using is_transparent = void;
+};
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_IDENTITY_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/invoke.h b/contrib/llvm-project/libcxx/include/__functional/invoke.h
new file mode 100644
index 000000000000..0e167c75d690
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/invoke.h
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_INVOKE_H
+#define _LIBCPP___FUNCTIONAL_INVOKE_H
+
+#include <__config>
+#include <__functional/weak_result_type.h>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Ret, bool = is_void<_Ret>::value>
+struct __invoke_void_return_wrapper
+{
+#ifndef _LIBCPP_CXX03_LANG
+ template <class ..._Args>
+ static _Ret __call(_Args&&... __args) {
+ return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
+ }
+#else
+ template <class _Fn>
+ static _Ret __call(_Fn __f) {
+ return _VSTD::__invoke(__f);
+ }
+
+ template <class _Fn, class _A0>
+ static _Ret __call(_Fn __f, _A0& __a0) {
+ return _VSTD::__invoke(__f, __a0);
+ }
+
+ template <class _Fn, class _A0, class _A1>
+ static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
+ return _VSTD::__invoke(__f, __a0, __a1);
+ }
+
+ template <class _Fn, class _A0, class _A1, class _A2>
+ static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
+ return _VSTD::__invoke(__f, __a0, __a1, __a2);
+ }
+#endif
+};
+
+template <class _Ret>
+struct __invoke_void_return_wrapper<_Ret, true>
+{
+#ifndef _LIBCPP_CXX03_LANG
+ template <class ..._Args>
+ static void __call(_Args&&... __args) {
+ _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
+ }
+#else
+ template <class _Fn>
+ static void __call(_Fn __f) {
+ _VSTD::__invoke(__f);
+ }
+
+ template <class _Fn, class _A0>
+ static void __call(_Fn __f, _A0& __a0) {
+ _VSTD::__invoke(__f, __a0);
+ }
+
+ template <class _Fn, class _A0, class _A1>
+ static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
+ _VSTD::__invoke(__f, __a0, __a1);
+ }
+
+ template <class _Fn, class _A0, class _A1, class _A2>
+ static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
+ _VSTD::__invoke(__f, __a0, __a1, __a2);
+ }
+#endif
+};
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Fn, class ..._Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
+invoke(_Fn&& __f, _Args&&... __args)
+ noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
+{
+ return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_INVOKE_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/is_transparent.h b/contrib/llvm-project/libcxx/include/__functional/is_transparent.h
new file mode 100644
index 000000000000..4a72aa8e29ee
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/is_transparent.h
@@ -0,0 +1,36 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
+#define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 11
+
+template <class _Tp, class, class = void>
+struct __is_transparent : false_type {};
+
+template <class _Tp, class _Up>
+struct __is_transparent<_Tp, _Up,
+ typename __void_t<typename _Tp::is_transparent>::type>
+ : true_type {};
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
diff --git a/contrib/llvm-project/libcxx/include/__functional/mem_fn.h b/contrib/llvm-project/libcxx/include/__functional/mem_fn.h
new file mode 100644
index 000000000000..1fa070a42cc9
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/mem_fn.h
@@ -0,0 +1,161 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_MEM_FN_H
+#define _LIBCPP___FUNCTIONAL_MEM_FN_H
+
+#include <__config>
+#include <__functional/weak_result_type.h>
+#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+class __mem_fn
+#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public __weak_result_type<_Tp>
+#endif
+{
+public:
+ // types
+ typedef _Tp type;
+private:
+ type __f_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ // invoke
+ template <class... _ArgTypes>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename __invoke_return<type, _ArgTypes...>::type
+ operator() (_ArgTypes&&... __args) const {
+ return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
+ }
+#else
+
+ template <class _A0>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return0<type, _A0>::type
+ operator() (_A0& __a0) const {
+ return _VSTD::__invoke(__f_, __a0);
+ }
+
+ template <class _A0>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return0<type, _A0 const>::type
+ operator() (_A0 const& __a0) const {
+ return _VSTD::__invoke(__f_, __a0);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0, _A1>::type
+ operator() (_A0& __a0, _A1& __a1) const {
+ return _VSTD::__invoke(__f_, __a0, __a1);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0 const, _A1>::type
+ operator() (_A0 const& __a0, _A1& __a1) const {
+ return _VSTD::__invoke(__f_, __a0, __a1);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0, _A1 const>::type
+ operator() (_A0& __a0, _A1 const& __a1) const {
+ return _VSTD::__invoke(__f_, __a0, __a1);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0 const, _A1 const>::type
+ operator() (_A0 const& __a0, _A1 const& __a1) const {
+ return _VSTD::__invoke(__f_, __a0, __a1);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1, _A2>::type
+ operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1, _A2>::type
+ operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1 const, _A2>::type
+ operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1, _A2 const>::type
+ operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
+ operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
+ operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
+ operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
+ operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(__f_, __a0, __a1, __a2);
+ }
+#endif
+};
+
+template<class _Rp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+__mem_fn<_Rp _Tp::*>
+mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
+{
+ return __mem_fn<_Rp _Tp::*>(__pm);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_MEM_FN_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/mem_fun_ref.h b/contrib/llvm-project/libcxx/include/__functional/mem_fun_ref.h
new file mode 100644
index 000000000000..4616da0b0748
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/mem_fun_ref.h
@@ -0,0 +1,173 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
+#define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+#include <__functional/binary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template<class _Sp, class _Tp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
+ : public unary_function<_Tp*, _Sp>
+{
+ _Sp (_Tp::*__p_)();
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
+ {return (__p->*__p_)();}
+};
+
+template<class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
+ : public binary_function<_Tp*, _Ap, _Sp>
+{
+ _Sp (_Tp::*__p_)(_Ap);
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
+ {return (__p->*__p_)(__x);}
+};
+
+template<class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+mem_fun_t<_Sp,_Tp>
+mem_fun(_Sp (_Tp::*__f)())
+ {return mem_fun_t<_Sp,_Tp>(__f);}
+
+template<class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+mem_fun1_t<_Sp,_Tp,_Ap>
+mem_fun(_Sp (_Tp::*__f)(_Ap))
+ {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
+
+template<class _Sp, class _Tp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
+ : public unary_function<_Tp, _Sp>
+{
+ _Sp (_Tp::*__p_)();
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
+ {return (__p.*__p_)();}
+};
+
+template<class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
+ : public binary_function<_Tp, _Ap, _Sp>
+{
+ _Sp (_Tp::*__p_)(_Ap);
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
+ {return (__p.*__p_)(__x);}
+};
+
+template<class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+mem_fun_ref_t<_Sp,_Tp>
+mem_fun_ref(_Sp (_Tp::*__f)())
+ {return mem_fun_ref_t<_Sp,_Tp>(__f);}
+
+template<class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+mem_fun1_ref_t<_Sp,_Tp,_Ap>
+mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
+ {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
+ : public unary_function<const _Tp*, _Sp>
+{
+ _Sp (_Tp::*__p_)() const;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
+ {return (__p->*__p_)();}
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
+ : public binary_function<const _Tp*, _Ap, _Sp>
+{
+ _Sp (_Tp::*__p_)(_Ap) const;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
+ {return (__p->*__p_)(__x);}
+};
+
+template <class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun_t<_Sp,_Tp>
+mem_fun(_Sp (_Tp::*__f)() const)
+ {return const_mem_fun_t<_Sp,_Tp>(__f);}
+
+template <class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun1_t<_Sp,_Tp,_Ap>
+mem_fun(_Sp (_Tp::*__f)(_Ap) const)
+ {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
+ : public unary_function<_Tp, _Sp>
+{
+ _Sp (_Tp::*__p_)() const;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
+ {return (__p.*__p_)();}
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
+ : public binary_function<_Tp, _Ap, _Sp>
+{
+ _Sp (_Tp::*__p_)(_Ap) const;
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
+ : __p_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
+ {return (__p.*__p_)(__x);}
+};
+
+template <class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun_ref_t<_Sp,_Tp>
+mem_fun_ref(_Sp (_Tp::*__f)() const)
+ {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
+
+template <class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
+mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
+ {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/not_fn.h b/contrib/llvm-project/libcxx/include/__functional/not_fn.h
new file mode 100644
index 000000000000..632be5ff096b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/not_fn.h
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_NOT_FN_H
+#define _LIBCPP___FUNCTIONAL_NOT_FN_H
+
+#include <__config>
+#include <__functional/perfect_forward.h>
+#include <__functional/invoke.h>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+struct __not_fn_op
+{
+ template<class... _Args>
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17 auto __call(_Args&&... __args)
+ noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
+ -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...))
+ { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); }
+};
+
+template<class _Fn,
+ class = _EnableIf<is_constructible_v<decay_t<_Fn>, _Fn> &&
+ is_move_constructible_v<_Fn>>>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f)
+{
+ return __perfect_forward<__not_fn_op, _Fn>(_VSTD::forward<_Fn>(__f));
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/operations.h b/contrib/llvm-project/libcxx/include/__functional/operations.h
new file mode 100644
index 000000000000..667d17988bc4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/operations.h
@@ -0,0 +1,729 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_OPERATIONS_H
+#define _LIBCPP___FUNCTIONAL_OPERATIONS_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/unary_function.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Arithmetic operations
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS plus
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x + __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS plus<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS minus
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x - __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS minus<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS multiplies
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x * __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS multiplies<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS divides
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x / __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS divides<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS modulus
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x % __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS modulus<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS negate
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : unary_function<_Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return -__x;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS negate<void>
+{
+ template <class _Tp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_Tp&& __x) const
+ _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
+ -> decltype (- _VSTD::forward<_Tp>(__x))
+ { return - _VSTD::forward<_Tp>(__x); }
+ typedef void is_transparent;
+};
+#endif
+
+// Bitwise operations
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS bit_and
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x & __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS bit_and<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER > 11
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp = void>
+struct _LIBCPP_TEMPLATE_VIS bit_not
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : unary_function<_Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x) const
+ {return ~__x;}
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS bit_not<void>
+{
+ template <class _Tp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_Tp&& __x) const
+ _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
+ -> decltype (~_VSTD::forward<_Tp>(__x))
+ { return ~_VSTD::forward<_Tp>(__x); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS bit_or
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x | __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS bit_or<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS bit_xor
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, _Tp>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef _Tp __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ _Tp operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x ^ __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+// Comparison operations
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS equal_to
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x == __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS equal_to<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS not_equal_to
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x != __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS less
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x < __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS less<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS less_equal
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x <= __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS less_equal<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS greater_equal
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x >= __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS greater
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x > __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS greater<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+// Logical operations
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS logical_and
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x && __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS logical_and<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS logical_not
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : unary_function<_Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x) const
+ {return !__x;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS logical_not<void>
+{
+ template <class _Tp>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_Tp&& __x) const
+ _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
+ -> decltype (!_VSTD::forward<_Tp>(__x))
+ { return !_VSTD::forward<_Tp>(__x); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS logical_or
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<_Tp, _Tp, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+ typedef bool __result_type; // used by valarray
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type;
+#endif
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const _Tp& __x, const _Tp& __y) const
+ {return __x || __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+struct _LIBCPP_TEMPLATE_VIS logical_or<void>
+{
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ auto operator()(_T1&& __t, _T2&& __u) const
+ _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
+ -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
+ { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/perfect_forward.h b/contrib/llvm-project/libcxx/include/__functional/perfect_forward.h
new file mode 100644
index 000000000000..a5678e1593bb
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/perfect_forward.h
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
+#define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
+
+#include <__config>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template<class _Op, class _Tuple,
+ class _Idxs = typename __make_tuple_indices<tuple_size<_Tuple>::value>::type>
+struct __perfect_forward_impl;
+
+template<class _Op, class... _Bound, size_t... _Idxs>
+struct __perfect_forward_impl<_Op, __tuple_types<_Bound...>, __tuple_indices<_Idxs...>>
+{
+ tuple<_Bound...> __bound_;
+
+ template<class... _Args>
+ _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) &
+ noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))
+ {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);}
+
+ template<class... _Args>
+ _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&
+ noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))
+ {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);}
+
+ template<class... _Args>
+ _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) &&
+ noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))...,
+ _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))...,
+ _VSTD::forward<_Args>(__args)...))
+ {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))...,
+ _VSTD::forward<_Args>(__args)...);}
+
+ template<class... _Args>
+ _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&&
+ noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))...,
+ _VSTD::forward<_Args>(__args)...)))
+ -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))...,
+ _VSTD::forward<_Args>(__args)...))
+ {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))...,
+ _VSTD::forward<_Args>(__args)...);}
+
+ template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type,
+ class = _EnableIf<is_copy_constructible_v<_Fn>>>
+ constexpr __perfect_forward_impl(__perfect_forward_impl const& __other)
+ : __bound_(__other.__bound_) {}
+
+ template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type,
+ class = _EnableIf<is_move_constructible_v<_Fn>>>
+ constexpr __perfect_forward_impl(__perfect_forward_impl && __other)
+ : __bound_(_VSTD::move(__other.__bound_)) {}
+
+ template<class... _BoundArgs>
+ explicit constexpr __perfect_forward_impl(_BoundArgs&&... __bound) :
+ __bound_(_VSTD::forward<_BoundArgs>(__bound)...) { }
+};
+
+template<class _Op, class... _Args>
+using __perfect_forward =
+ __perfect_forward_impl<_Op, __tuple_types<decay_t<_Args>...>>;
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/pointer_to_binary_function.h b/contrib/llvm-project/libcxx/include/__functional/pointer_to_binary_function.h
new file mode 100644
index 000000000000..d4a6c1674aec
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/pointer_to_binary_function.h
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Arg1, class _Arg2, class _Result>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
+ : public binary_function<_Arg1, _Arg2, _Result>
+{
+ _Result (*__f_)(_Arg1, _Arg2);
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
+ : __f_(__f) {}
+ _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
+ {return __f_(__x, __y);}
+};
+
+template <class _Arg1, class _Arg2, class _Result>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+pointer_to_binary_function<_Arg1,_Arg2,_Result>
+ptr_fun(_Result (*__f)(_Arg1,_Arg2))
+ {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/pointer_to_unary_function.h b/contrib/llvm-project/libcxx/include/__functional/pointer_to_unary_function.h
new file mode 100644
index 000000000000..0ac4561cc305
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/pointer_to_unary_function.h
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Arg, class _Result>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
+ : public unary_function<_Arg, _Result>
+{
+ _Result (*__f_)(_Arg);
+public:
+ _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
+ : __f_(__f) {}
+ _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
+ {return __f_(__x);}
+};
+
+template <class _Arg, class _Result>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
+pointer_to_unary_function<_Arg,_Result>
+ptr_fun(_Result (*__f)(_Arg))
+ {return pointer_to_unary_function<_Arg,_Result>(__f);}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h b/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h
new file mode 100644
index 000000000000..777c53525102
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/ranges_operations.h
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
+#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
+
+#include <__config>
+#include <concepts>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+namespace ranges {
+
+struct equal_to {
+ template <class _Tp, class _Up>
+ requires equality_comparable_with<_Tp, _Up>
+ [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
+ noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) {
+ return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u);
+ }
+
+ using is_transparent = void;
+};
+
+struct not_equal_to {
+ template <class _Tp, class _Up>
+ requires equality_comparable_with<_Tp, _Up>
+ [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
+ noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) {
+ return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u));
+ }
+
+ using is_transparent = void;
+};
+
+struct less {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
+ noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) {
+ return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u);
+ }
+
+ using is_transparent = void;
+};
+
+struct less_equal {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
+ noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) {
+ return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t));
+ }
+
+ using is_transparent = void;
+};
+
+struct greater {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
+ noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) {
+ return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t);
+ }
+
+ using is_transparent = void;
+};
+
+struct greater_equal {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const
+ noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) {
+ return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u));
+ }
+
+ using is_transparent = void;
+};
+
+} // namespace ranges
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/reference_wrapper.h b/contrib/llvm-project/libcxx/include/__functional/reference_wrapper.h
new file mode 100644
index 000000000000..09f4a6494502
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/reference_wrapper.h
@@ -0,0 +1,223 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
+#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
+
+#include <__config>
+#include <__functional/weak_result_type.h>
+#include <__memory/addressof.h>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS reference_wrapper
+#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : public __weak_result_type<_Tp>
+#endif
+{
+public:
+ // types
+ typedef _Tp type;
+private:
+ type* __f_;
+
+#ifndef _LIBCPP_CXX03_LANG
+ static void __fun(_Tp&) _NOEXCEPT;
+ static void __fun(_Tp&&) = delete;
+#endif
+
+public:
+ // construct/copy/destroy
+#ifdef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ reference_wrapper(type& __f) _NOEXCEPT
+ : __f_(_VSTD::addressof(__f)) {}
+#else
+ template <class _Up, class = _EnableIf<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) >>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) {
+ type& __f = static_cast<_Up&&>(__u);
+ __f_ = _VSTD::addressof(__f);
+ }
+#endif
+
+ // access
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ operator type&() const _NOEXCEPT {return *__f_;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ type& get() const _NOEXCEPT {return *__f_;}
+
+#ifndef _LIBCPP_CXX03_LANG
+ // invoke
+ template <class... _ArgTypes>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ typename __invoke_of<type&, _ArgTypes...>::type
+ operator() (_ArgTypes&&... __args) const {
+ return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
+ }
+#else
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return<type>::type
+ operator() () const {
+ return _VSTD::__invoke(get());
+ }
+
+ template <class _A0>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return0<type, _A0>::type
+ operator() (_A0& __a0) const {
+ return _VSTD::__invoke(get(), __a0);
+ }
+
+ template <class _A0>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return0<type, _A0 const>::type
+ operator() (_A0 const& __a0) const {
+ return _VSTD::__invoke(get(), __a0);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0, _A1>::type
+ operator() (_A0& __a0, _A1& __a1) const {
+ return _VSTD::__invoke(get(), __a0, __a1);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0 const, _A1>::type
+ operator() (_A0 const& __a0, _A1& __a1) const {
+ return _VSTD::__invoke(get(), __a0, __a1);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0, _A1 const>::type
+ operator() (_A0& __a0, _A1 const& __a1) const {
+ return _VSTD::__invoke(get(), __a0, __a1);
+ }
+
+ template <class _A0, class _A1>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return1<type, _A0 const, _A1 const>::type
+ operator() (_A0 const& __a0, _A1 const& __a1) const {
+ return _VSTD::__invoke(get(), __a0, __a1);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1, _A2>::type
+ operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1, _A2>::type
+ operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1 const, _A2>::type
+ operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1, _A2 const>::type
+ operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
+ operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
+ operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
+ operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+
+ template <class _A0, class _A1, class _A2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
+ operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
+ return _VSTD::__invoke(get(), __a0, __a1, __a2);
+ }
+#endif // _LIBCPP_CXX03_LANG
+};
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template <class _Tp>
+reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+reference_wrapper<_Tp>
+ref(_Tp& __t) _NOEXCEPT
+{
+ return reference_wrapper<_Tp>(__t);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+reference_wrapper<_Tp>
+ref(reference_wrapper<_Tp> __t) _NOEXCEPT
+{
+ return _VSTD::ref(__t.get());
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+reference_wrapper<const _Tp>
+cref(const _Tp& __t) _NOEXCEPT
+{
+ return reference_wrapper<const _Tp>(__t);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+reference_wrapper<const _Tp>
+cref(reference_wrapper<_Tp> __t) _NOEXCEPT
+{
+ return _VSTD::cref(__t.get());
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp> void ref(const _Tp&&) = delete;
+template <class _Tp> void cref(const _Tp&&) = delete;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/unary_function.h b/contrib/llvm-project/libcxx/include/__functional/unary_function.h
new file mode 100644
index 000000000000..8084ef4b0343
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/unary_function.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Arg, class _Result>
+struct _LIBCPP_TEMPLATE_VIS unary_function
+{
+ typedef _Arg argument_type;
+ typedef _Result result_type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/unary_negate.h b/contrib/llvm-project/libcxx/include/__functional/unary_negate.h
new file mode 100644
index 000000000000..71257cf40c0d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/unary_negate.h
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H
+#define _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+template <class _Predicate>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
+ : public unary_function<typename _Predicate::argument_type, bool>
+{
+ _Predicate __pred_;
+public:
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ explicit unary_negate(const _Predicate& __pred)
+ : __pred_(__pred) {}
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ bool operator()(const typename _Predicate::argument_type& __x) const
+ {return !__pred_(__x);}
+};
+
+template <class _Predicate>
+_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+unary_negate<_Predicate>
+not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
+
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/unwrap_ref.h b/contrib/llvm-project/libcxx/include/__functional/unwrap_ref.h
new file mode 100644
index 000000000000..4d091ec35c5d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/unwrap_ref.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
+#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
+
+template <class _Tp>
+class reference_wrapper;
+
+template <class _Tp>
+struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
+
+template <class _Tp>
+struct decay;
+
+#if _LIBCPP_STD_VER > 17
+template <class _Tp>
+struct unwrap_reference : __unwrap_reference<_Tp> { };
+
+template <class _Tp>
+using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
+
+template <class _Tp>
+struct unwrap_ref_decay : unwrap_reference<typename decay<_Tp>::type> { };
+
+template <class _Tp>
+using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
+#endif // > C++17
+
+template <class _Tp>
+struct __unwrap_ref_decay
+#if _LIBCPP_STD_VER > 17
+ : unwrap_ref_decay<_Tp>
+#else
+ : __unwrap_reference<typename decay<_Tp>::type>
+#endif
+{ };
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
diff --git a/contrib/llvm-project/libcxx/include/__functional/weak_result_type.h b/contrib/llvm-project/libcxx/include/__functional/weak_result_type.h
new file mode 100644
index 000000000000..2ee85acf1ef4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__functional/weak_result_type.h
@@ -0,0 +1,481 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
+#define _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/unary_function.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __has_result_type
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::result_type* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+// __weak_result_type
+
+template <class _Tp>
+struct __derives_from_unary_function
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ static __two __test(...);
+ template <class _Ap, class _Rp>
+ static unary_function<_Ap, _Rp>
+ __test(const volatile unary_function<_Ap, _Rp>*);
+public:
+ static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
+ typedef decltype(__test((_Tp*)0)) type;
+};
+
+template <class _Tp>
+struct __derives_from_binary_function
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ static __two __test(...);
+ template <class _A1, class _A2, class _Rp>
+ static binary_function<_A1, _A2, _Rp>
+ __test(const volatile binary_function<_A1, _A2, _Rp>*);
+public:
+ static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
+ typedef decltype(__test((_Tp*)0)) type;
+};
+
+template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
+struct __maybe_derive_from_unary_function // bool is true
+ : public __derives_from_unary_function<_Tp>::type
+{
+};
+
+template <class _Tp>
+struct __maybe_derive_from_unary_function<_Tp, false>
+{
+};
+
+template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
+struct __maybe_derive_from_binary_function // bool is true
+ : public __derives_from_binary_function<_Tp>::type
+{
+};
+
+template <class _Tp>
+struct __maybe_derive_from_binary_function<_Tp, false>
+{
+};
+
+template <class _Tp, bool = __has_result_type<_Tp>::value>
+struct __weak_result_type_imp // bool is true
+ : public __maybe_derive_from_unary_function<_Tp>,
+ public __maybe_derive_from_binary_function<_Tp>
+{
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type;
+};
+
+template <class _Tp>
+struct __weak_result_type_imp<_Tp, false>
+ : public __maybe_derive_from_unary_function<_Tp>,
+ public __maybe_derive_from_binary_function<_Tp>
+{
+};
+
+template <class _Tp>
+struct __weak_result_type
+ : public __weak_result_type_imp<_Tp>
+{
+};
+
+// 0 argument case
+
+template <class _Rp>
+struct __weak_result_type<_Rp ()>
+{
+ typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
+};
+
+template <class _Rp>
+struct __weak_result_type<_Rp (&)()>
+{
+ typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
+};
+
+template <class _Rp>
+struct __weak_result_type<_Rp (*)()>
+{
+ typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
+};
+
+// 1 argument case
+
+template <class _Rp, class _A1>
+struct __weak_result_type<_Rp (_A1)>
+ : public unary_function<_A1, _Rp>
+{
+};
+
+template <class _Rp, class _A1>
+struct __weak_result_type<_Rp (&)(_A1)>
+ : public unary_function<_A1, _Rp>
+{
+};
+
+template <class _Rp, class _A1>
+struct __weak_result_type<_Rp (*)(_A1)>
+ : public unary_function<_A1, _Rp>
+{
+};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)()>
+ : public unary_function<_Cp*, _Rp>
+{
+};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)() const>
+ : public unary_function<const _Cp*, _Rp>
+{
+};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)() volatile>
+ : public unary_function<volatile _Cp*, _Rp>
+{
+};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)() const volatile>
+ : public unary_function<const volatile _Cp*, _Rp>
+{
+};
+
+// 2 argument case
+
+template <class _Rp, class _A1, class _A2>
+struct __weak_result_type<_Rp (_A1, _A2)>
+ : public binary_function<_A1, _A2, _Rp>
+{
+};
+
+template <class _Rp, class _A1, class _A2>
+struct __weak_result_type<_Rp (*)(_A1, _A2)>
+ : public binary_function<_A1, _A2, _Rp>
+{
+};
+
+template <class _Rp, class _A1, class _A2>
+struct __weak_result_type<_Rp (&)(_A1, _A2)>
+ : public binary_function<_A1, _A2, _Rp>
+{
+};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1)>
+ : public binary_function<_Cp*, _A1, _Rp>
+{
+};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
+ : public binary_function<const _Cp*, _A1, _Rp>
+{
+};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
+ : public binary_function<volatile _Cp*, _A1, _Rp>
+{
+};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
+ : public binary_function<const volatile _Cp*, _A1, _Rp>
+{
+};
+
+
+#ifndef _LIBCPP_CXX03_LANG
+// 3 or more arguments
+
+template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
+struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
+struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
+struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
+{
+ typedef _Rp result_type;
+};
+
+template <class _Tp, class ..._Args>
+struct __invoke_return
+{
+ typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
+};
+
+#else // defined(_LIBCPP_CXX03_LANG)
+
+template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
+struct __enable_invoke_imp;
+
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, true, true> {
+ typedef _Ret _Bullet1;
+ typedef _Bullet1 type;
+};
+
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, true, false> {
+ typedef _Ret _Bullet2;
+ typedef _Bullet2 type;
+};
+
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, false, true> {
+ typedef typename add_lvalue_reference<
+ typename __apply_cv<_T1, _Ret>::type
+ >::type _Bullet3;
+ typedef _Bullet3 type;
+};
+
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1, false, false> {
+ typedef typename add_lvalue_reference<
+ typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
+ >::type _Bullet4;
+ typedef _Bullet4 type;
+};
+
+template <class _Ret, class _T1>
+struct __enable_invoke_imp<_Ret, _T1*, false, false> {
+ typedef typename add_lvalue_reference<
+ typename __apply_cv<_T1, _Ret>::type
+ >::type _Bullet4;
+ typedef _Bullet4 type;
+};
+
+template <class _Fn, class _T1,
+ class _Traits = __member_pointer_traits<_Fn>,
+ class _Ret = typename _Traits::_ReturnType,
+ class _Class = typename _Traits::_ClassType>
+struct __enable_invoke : __enable_invoke_imp<
+ _Ret, _T1,
+ is_member_function_pointer<_Fn>::value,
+ is_base_of<_Class, typename remove_reference<_T1>::type>::value>
+{
+};
+
+__nat __invoke(__any, ...);
+
+// first bullet
+
+template <class _Fn, class _T1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1) {
+ return (__t1.*__f)();
+}
+
+template <class _Fn, class _T1, class _A0>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
+ return (__t1.*__f)(__a0);
+}
+
+template <class _Fn, class _T1, class _A0, class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
+ return (__t1.*__f)(__a0, __a1);
+}
+
+template <class _Fn, class _T1, class _A0, class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet1
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
+ return (__t1.*__f)(__a0, __a1, __a2);
+}
+
+template <class _Fn, class _T1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1) {
+ return ((*__t1).*__f)();
+}
+
+template <class _Fn, class _T1, class _A0>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
+ return ((*__t1).*__f)(__a0);
+}
+
+template <class _Fn, class _T1, class _A0, class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
+ return ((*__t1).*__f)(__a0, __a1);
+}
+
+template <class _Fn, class _T1, class _A0, class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet2
+__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
+ return ((*__t1).*__f)(__a0, __a1, __a2);
+}
+
+template <class _Fn, class _T1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet3
+__invoke(_Fn __f, _T1& __t1) {
+ return __t1.*__f;
+}
+
+template <class _Fn, class _T1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __enable_invoke<_Fn, _T1>::_Bullet4
+__invoke(_Fn __f, _T1& __t1) {
+ return (*__t1).*__f;
+}
+
+// fifth bullet
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(declval<_Fp&>()())
+__invoke(_Fp& __f)
+{
+ return __f();
+}
+
+template <class _Fp, class _A0>
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(declval<_Fp&>()(declval<_A0&>()))
+__invoke(_Fp& __f, _A0& __a0)
+{
+ return __f(__a0);
+}
+
+template <class _Fp, class _A0, class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
+__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
+{
+ return __f(__a0, __a1);
+}
+
+template <class _Fp, class _A0, class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
+__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
+{
+ return __f(__a0, __a1, __a2);
+}
+
+template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
+struct __invoke_return
+{
+ typedef typename __weak_result_type<_Fp>::result_type type;
+};
+
+template <class _Fp>
+struct __invoke_return<_Fp, false>
+{
+ typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
+};
+
+template <class _Tp, class _A0>
+struct __invoke_return0
+{
+ typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
+};
+
+template <class _Rp, class _Tp, class _A0>
+struct __invoke_return0<_Rp _Tp::*, _A0>
+{
+ typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
+};
+
+template <class _Tp, class _A0, class _A1>
+struct __invoke_return1
+{
+ typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
+ declval<_A1&>())) type;
+};
+
+template <class _Rp, class _Class, class _A0, class _A1>
+struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
+ typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
+};
+
+template <class _Tp, class _A0, class _A1, class _A2>
+struct __invoke_return2
+{
+ typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
+ declval<_A1&>(),
+ declval<_A2&>())) type;
+};
+
+template <class _Ret, class _Class, class _A0, class _A1, class _A2>
+struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
+ typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
+};
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
diff --git a/contrib/llvm-project/libcxx/include/__functional_base b/contrib/llvm-project/libcxx/include/__functional_base
index 1c02e960d5f0..ccc3f3a58ca5 100644
--- a/contrib/llvm-project/libcxx/include/__functional_base
+++ b/contrib/llvm-project/libcxx/include/__functional_base
@@ -11,645 +11,22 @@
#define _LIBCPP_FUNCTIONAL_BASE
#include <__config>
-#include <type_traits>
-#include <typeinfo>
+#include <__functional/binary_function.h>
+#include <__functional/invoke.h>
+#include <__functional/operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__functional/unary_function.h>
+#include <__functional/weak_result_type.h>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
#include <exception>
#include <new>
+#include <type_traits>
+#include <typeinfo>
#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Arg1, class _Arg2, class _Result>
-struct _LIBCPP_TEMPLATE_VIS binary_function
-{
- typedef _Arg1 first_argument_type;
- typedef _Arg2 second_argument_type;
- typedef _Result result_type;
-};
-
-template <class _Tp>
-struct __has_result_type
-{
-private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::result_type* = 0);
-public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x < __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS less<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-// __weak_result_type
-
-template <class _Tp>
-struct __derives_from_unary_function
-{
-private:
- struct __two {char __lx; char __lxx;};
- static __two __test(...);
- template <class _Ap, class _Rp>
- static unary_function<_Ap, _Rp>
- __test(const volatile unary_function<_Ap, _Rp>*);
-public:
- static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
- typedef decltype(__test((_Tp*)0)) type;
-};
-
-template <class _Tp>
-struct __derives_from_binary_function
-{
-private:
- struct __two {char __lx; char __lxx;};
- static __two __test(...);
- template <class _A1, class _A2, class _Rp>
- static binary_function<_A1, _A2, _Rp>
- __test(const volatile binary_function<_A1, _A2, _Rp>*);
-public:
- static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
- typedef decltype(__test((_Tp*)0)) type;
-};
-
-template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
-struct __maybe_derive_from_unary_function // bool is true
- : public __derives_from_unary_function<_Tp>::type
-{
-};
-
-template <class _Tp>
-struct __maybe_derive_from_unary_function<_Tp, false>
-{
-};
-
-template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
-struct __maybe_derive_from_binary_function // bool is true
- : public __derives_from_binary_function<_Tp>::type
-{
-};
-
-template <class _Tp>
-struct __maybe_derive_from_binary_function<_Tp, false>
-{
-};
-
-template <class _Tp, bool = __has_result_type<_Tp>::value>
-struct __weak_result_type_imp // bool is true
- : public __maybe_derive_from_unary_function<_Tp>,
- public __maybe_derive_from_binary_function<_Tp>
-{
- typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type;
-};
-
-template <class _Tp>
-struct __weak_result_type_imp<_Tp, false>
- : public __maybe_derive_from_unary_function<_Tp>,
- public __maybe_derive_from_binary_function<_Tp>
-{
-};
-
-template <class _Tp>
-struct __weak_result_type
- : public __weak_result_type_imp<_Tp>
-{
-};
-
-// 0 argument case
-
-template <class _Rp>
-struct __weak_result_type<_Rp ()>
-{
- typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
-};
-
-template <class _Rp>
-struct __weak_result_type<_Rp (&)()>
-{
- typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
-};
-
-template <class _Rp>
-struct __weak_result_type<_Rp (*)()>
-{
- typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
-};
-
-// 1 argument case
-
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (_A1)>
- : public unary_function<_A1, _Rp>
-{
-};
-
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (&)(_A1)>
- : public unary_function<_A1, _Rp>
-{
-};
-
-template <class _Rp, class _A1>
-struct __weak_result_type<_Rp (*)(_A1)>
- : public unary_function<_A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)()>
- : public unary_function<_Cp*, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)() const>
- : public unary_function<const _Cp*, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)() volatile>
- : public unary_function<volatile _Cp*, _Rp>
-{
-};
-
-template <class _Rp, class _Cp>
-struct __weak_result_type<_Rp (_Cp::*)() const volatile>
- : public unary_function<const volatile _Cp*, _Rp>
-{
-};
-
-// 2 argument case
-
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (*)(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Rp, class _A1, class _A2>
-struct __weak_result_type<_Rp (&)(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1)>
- : public binary_function<_Cp*, _A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
- : public binary_function<const _Cp*, _A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
- : public binary_function<volatile _Cp*, _A1, _Rp>
-{
-};
-
-template <class _Rp, class _Cp, class _A1>
-struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
- : public binary_function<const volatile _Cp*, _A1, _Rp>
-{
-};
-
-
-#ifndef _LIBCPP_CXX03_LANG
-// 3 or more arguments
-
-template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
-struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
-{
- typedef _Rp result_type;
-};
-
-template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
-struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
-{
- typedef _Rp result_type;
-};
-
-template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
-struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
-{
- typedef _Rp result_type;
-};
-
-template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
-{
- typedef _Rp result_type;
-};
-
-template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
-{
- typedef _Rp result_type;
-};
-
-template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
-{
- typedef _Rp result_type;
-};
-
-template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
-struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
-{
- typedef _Rp result_type;
-};
-
-template <class _Tp, class ..._Args>
-struct __invoke_return
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
-};
-
-#else // defined(_LIBCPP_CXX03_LANG)
-
-#include <__functional_base_03>
-
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
-
-template <class _Ret, bool = is_void<_Ret>::value>
-struct __invoke_void_return_wrapper
-{
-#ifndef _LIBCPP_CXX03_LANG
- template <class ..._Args>
- static _Ret __call(_Args&&... __args) {
- return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
- }
-#else
- template <class _Fn>
- static _Ret __call(_Fn __f) {
- return _VSTD::__invoke(__f);
- }
-
- template <class _Fn, class _A0>
- static _Ret __call(_Fn __f, _A0& __a0) {
- return _VSTD::__invoke(__f, __a0);
- }
-
- template <class _Fn, class _A0, class _A1>
- static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
- return _VSTD::__invoke(__f, __a0, __a1);
- }
-
- template <class _Fn, class _A0, class _A1, class _A2>
- static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
- return _VSTD::__invoke(__f, __a0, __a1, __a2);
- }
-#endif
-};
-
-template <class _Ret>
-struct __invoke_void_return_wrapper<_Ret, true>
-{
-#ifndef _LIBCPP_CXX03_LANG
- template <class ..._Args>
- static void __call(_Args&&... __args) {
- _VSTD::__invoke(_VSTD::forward<_Args>(__args)...);
- }
-#else
- template <class _Fn>
- static void __call(_Fn __f) {
- _VSTD::__invoke(__f);
- }
-
- template <class _Fn, class _A0>
- static void __call(_Fn __f, _A0& __a0) {
- _VSTD::__invoke(__f, __a0);
- }
-
- template <class _Fn, class _A0, class _A1>
- static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
- _VSTD::__invoke(__f, __a0, __a1);
- }
-
- template <class _Fn, class _A0, class _A1, class _A2>
- static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
- _VSTD::__invoke(__f, __a0, __a1, __a2);
- }
-#endif
-};
-
-template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS reference_wrapper
- : public __weak_result_type<_Tp>
-{
-public:
- // types
- typedef _Tp type;
-private:
- type* __f_;
-
-public:
- // construct/copy/destroy
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- reference_wrapper(type& __f) _NOEXCEPT
- : __f_(_VSTD::addressof(__f)) {}
-#ifndef _LIBCPP_CXX03_LANG
- private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
-#endif
-
- // access
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- operator type&() const _NOEXCEPT {return *__f_;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- type& get() const _NOEXCEPT {return *__f_;}
-
-#ifndef _LIBCPP_CXX03_LANG
- // invoke
- template <class... _ArgTypes>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename __invoke_of<type&, _ArgTypes...>::type
- operator() (_ArgTypes&&... __args) const {
- return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
- }
-#else
-
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return<type>::type
- operator() () const {
- return _VSTD::__invoke(get());
- }
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0>::type
- operator() (_A0& __a0) const {
- return _VSTD::__invoke(get(), __a0);
- }
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0 const>::type
- operator() (_A0 const& __a0) const {
- return _VSTD::__invoke(get(), __a0);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1>::type
- operator() (_A0& __a0, _A1& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1>::type
- operator() (_A0 const& __a0, _A1& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1 const>::type
- operator() (_A0& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(get(), __a0, __a1);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2>::type
- operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2 const>::type
- operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(get(), __a0, __a1, __a2);
- }
-#endif // _LIBCPP_CXX03_LANG
-};
-
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-reference_wrapper<_Tp>
-ref(_Tp& __t) _NOEXCEPT
-{
- return reference_wrapper<_Tp>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-reference_wrapper<_Tp>
-ref(reference_wrapper<_Tp> __t) _NOEXCEPT
-{
- return _VSTD::ref(__t.get());
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-reference_wrapper<const _Tp>
-cref(const _Tp& __t) _NOEXCEPT
-{
- return reference_wrapper<const _Tp>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-reference_wrapper<const _Tp>
-cref(reference_wrapper<_Tp> __t) _NOEXCEPT
-{
- return _VSTD::cref(__t.get());
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Tp> void ref(const _Tp&&) = delete;
-template <class _Tp> void cref(const _Tp&&) = delete;
-#endif
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp, class, class = void>
-struct __is_transparent : false_type {};
-
-template <class _Tp, class _Up>
-struct __is_transparent<_Tp, _Up,
- typename __void_t<typename _Tp::is_transparent>::type>
- : true_type {};
-#endif
-
-// allocator_arg_t
-
-struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; };
-
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
-extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
-#else
-/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
-#endif
-
-// uses_allocator
-
-template <class _Tp>
-struct __has_allocator_type
-{
-private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::allocator_type* = 0);
-public:
- static const bool value = sizeof(__test<_Tp>(0)) == 1;
-};
-
-template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
-struct __uses_allocator
- : public integral_constant<bool,
- is_convertible<_Alloc, typename _Tp::allocator_type>::value>
-{
-};
-
-template <class _Tp, class _Alloc>
-struct __uses_allocator<_Tp, _Alloc, false>
- : public false_type
-{
-};
-
-template <class _Tp, class _Alloc>
-struct _LIBCPP_TEMPLATE_VIS uses_allocator
- : public __uses_allocator<_Tp, _Alloc>
-{
-};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp, class _Alloc>
-_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
-#endif
-
-#ifndef _LIBCPP_CXX03_LANG
-
-// allocator construction
-
-template <class _Tp, class _Alloc, class ..._Args>
-struct __uses_alloc_ctor_imp
-{
- typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc;
- static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
- static const bool __ic =
- is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
- static const int value = __ua ? 2 - __ic : 0;
-};
-
-template <class _Tp, class _Alloc, class ..._Args>
-struct __uses_alloc_ctor
- : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
- {};
-
-template <class _Tp, class _Allocator, class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
-{
- new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
-}
-
-// FIXME: This should have a version which takes a non-const alloc.
-template <class _Tp, class _Allocator, class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
-{
- new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
-}
-
-// FIXME: This should have a version which takes a non-const alloc.
-template <class _Tp, class _Allocator, class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
-{
- new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP_FUNCTIONAL_BASE
+#endif // _LIBCPP_FUNCTIONAL_BASE
diff --git a/contrib/llvm-project/libcxx/include/__functional_base_03 b/contrib/llvm-project/libcxx/include/__functional_base_03
deleted file mode 100644
index 9b08bd26a8fd..000000000000
--- a/contrib/llvm-project/libcxx/include/__functional_base_03
+++ /dev/null
@@ -1,223 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_FUNCTIONAL_BASE_03
-#define _LIBCPP_FUNCTIONAL_BASE_03
-
-// manual variadic expansion for <functional>
-
-// __invoke
-
-template <class _Ret, class _T1, bool _IsFunc, bool _IsBase>
-struct __enable_invoke_imp;
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, true, true> {
- typedef _Ret _Bullet1;
- typedef _Bullet1 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, true, false> {
- typedef _Ret _Bullet2;
- typedef _Bullet2 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, false, true> {
- typedef typename add_lvalue_reference<
- typename __apply_cv<_T1, _Ret>::type
- >::type _Bullet3;
- typedef _Bullet3 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1, false, false> {
- typedef typename add_lvalue_reference<
- typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type
- >::type _Bullet4;
- typedef _Bullet4 type;
-};
-
-template <class _Ret, class _T1>
-struct __enable_invoke_imp<_Ret, _T1*, false, false> {
- typedef typename add_lvalue_reference<
- typename __apply_cv<_T1, _Ret>::type
- >::type _Bullet4;
- typedef _Bullet4 type;
-};
-
-template <class _Fn, class _T1,
- class _Traits = __member_pointer_traits<_Fn>,
- class _Ret = typename _Traits::_ReturnType,
- class _Class = typename _Traits::_ClassType>
-struct __enable_invoke : __enable_invoke_imp<
- _Ret, _T1,
- is_member_function_pointer<_Fn>::value,
- is_base_of<_Class, typename remove_reference<_T1>::type>::value>
-{
-};
-
-__nat __invoke(__any, ...);
-
-// first bullet
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1) {
- return (__t1.*__f)();
-}
-
-template <class _Fn, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
- return (__t1.*__f)(__a0);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
- return (__t1.*__f)(__a0, __a1);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet1
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
- return (__t1.*__f)(__a0, __a1, __a2);
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1) {
- return ((*__t1).*__f)();
-}
-
-template <class _Fn, class _T1, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0) {
- return ((*__t1).*__f)(__a0);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) {
- return ((*__t1).*__f)(__a0, __a1);
-}
-
-template <class _Fn, class _T1, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet2
-__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) {
- return ((*__t1).*__f)(__a0, __a1, __a2);
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet3
-__invoke(_Fn __f, _T1& __t1) {
- return __t1.*__f;
-}
-
-template <class _Fn, class _T1>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __enable_invoke<_Fn, _T1>::_Bullet4
-__invoke(_Fn __f, _T1& __t1) {
- return (*__t1).*__f;
-}
-
-// fifth bullet
-
-template <class _Fp>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()())
-__invoke(_Fp& __f)
-{
- return __f();
-}
-
-template <class _Fp, class _A0>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>()))
-__invoke(_Fp& __f, _A0& __a0)
-{
- return __f(__a0);
-}
-
-template <class _Fp, class _A0, class _A1>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>()))
-__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
-{
- return __f(__a0, __a1);
-}
-
-template <class _Fp, class _A0, class _A1, class _A2>
-inline _LIBCPP_INLINE_VISIBILITY
-decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
-__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
-{
- return __f(__a0, __a1, __a2);
-}
-
-template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
-struct __invoke_return
-{
- typedef typename __weak_result_type<_Fp>::result_type type;
-};
-
-template <class _Fp>
-struct __invoke_return<_Fp, false>
-{
- typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type;
-};
-
-template <class _Tp, class _A0>
-struct __invoke_return0
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type;
-};
-
-template <class _Rp, class _Tp, class _A0>
-struct __invoke_return0<_Rp _Tp::*, _A0>
-{
- typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type;
-};
-
-template <class _Tp, class _A0, class _A1>
-struct __invoke_return1
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
- declval<_A1&>())) type;
-};
-
-template <class _Rp, class _Class, class _A0, class _A1>
-struct __invoke_return1<_Rp _Class::*, _A0, _A1> {
- typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type;
-};
-
-template <class _Tp, class _A0, class _A1, class _A2>
-struct __invoke_return2
-{
- typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(),
- declval<_A1&>(),
- declval<_A2&>())) type;
-};
-
-template <class _Ret, class _Class, class _A0, class _A1, class _A2>
-struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> {
- typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type;
-};
-#endif // _LIBCPP_FUNCTIONAL_BASE_03
diff --git a/contrib/llvm-project/libcxx/include/__hash_table b/contrib/llvm-project/libcxx/include/__hash_table
index 521ebbf2c45f..df0f7c80db2e 100644
--- a/contrib/llvm-project/libcxx/include/__hash_table
+++ b/contrib/llvm-project/libcxx/include/__hash_table
@@ -10,16 +10,16 @@
#ifndef _LIBCPP__HASH_TABLE
#define _LIBCPP__HASH_TABLE
+#include <__bits> // __libcpp_clz
#include <__config>
-#include <initializer_list>
-#include <memory>
-#include <iterator>
+#include <__debug>
#include <algorithm>
#include <cmath>
-#include <utility>
+#include <initializer_list>
+#include <iterator>
+#include <memory>
#include <type_traits>
-
-#include <__debug>
+#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -89,7 +89,7 @@ struct __hash_node_base
};
template <class _Tp, class _VoidPtr>
-struct __hash_node
+struct _LIBCPP_STANDALONE_DEBUG __hash_node
: public __hash_node_base
<
typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
@@ -317,7 +317,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -336,7 +336,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__hash_iterator& operator++() {
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable unordered container iterator");
+ "Attempted to increment a non-incrementable unordered container iterator");
__node_ = __node_->__next_;
return *this;
}
@@ -438,7 +438,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -456,7 +456,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator& operator++() {
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable unordered container const_iterator");
+ "Attempted to increment a non-incrementable unordered container const_iterator");
__node_ = __node_->__next_;
return *this;
}
@@ -550,7 +550,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -569,7 +569,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__hash_local_iterator& operator++() {
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable unordered container local_iterator");
+ "Attempted to increment a non-incrementable unordered container local_iterator");
__node_ = __node_->__next_;
if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
__node_ = nullptr;
@@ -695,7 +695,7 @@ public:
}
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const {
@@ -714,7 +714,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__hash_const_local_iterator& operator++() {
_LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable unordered container const_local_iterator");
+ "Attempted to increment a non-incrementable unordered container const_local_iterator");
__node_ = __node_->__next_;
if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
__node_ = nullptr;
@@ -741,9 +741,9 @@ public:
private:
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
- __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
+ __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
size_t __bucket_count, const void* __c) _NOEXCEPT
- : __node_(__node),
+ : __node_(__node_ptr),
__bucket_(__bucket),
__bucket_count_(__bucket_count)
{
@@ -753,9 +753,9 @@ private:
}
#else
_LIBCPP_INLINE_VISIBILITY
- __hash_const_local_iterator(__next_pointer __node, size_t __bucket,
+ __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket,
size_t __bucket_count) _NOEXCEPT
- : __node_(__node),
+ : __node_(__node_ptr),
__bucket_(__bucket),
__bucket_count_(__bucket_count)
{
@@ -1337,7 +1337,7 @@ public:
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
void __rehash(size_type __n);
@@ -1645,7 +1645,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
const_iterator __i = __u.begin();
while (__cache != nullptr && __u.size() != 0)
{
@@ -1662,7 +1662,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
__deallocate_node(__cache);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__deallocate_node(__cache);
}
const_iterator __i = __u.begin();
@@ -1707,7 +1707,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __cache != nullptr && __first != __last; ++__first)
{
__cache->__upcast()->__value_ = *__first;
@@ -1722,7 +1722,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first
__deallocate_node(__cache);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__deallocate_node(__cache);
}
for (; __first != __last; ++__first)
@@ -1747,7 +1747,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __cache != nullptr && __first != __last; ++__first)
{
__cache->__upcast()->__value_ = *__first;
@@ -1762,7 +1762,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
__deallocate_node(__cache);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__deallocate_node(__cache);
}
for (; __first != __last; ++__first)
@@ -2299,7 +2299,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
__node_insert_multi_perform(__src_ptr, __pn);
}
}
-#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER > 14
template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
@@ -2506,11 +2506,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
{
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
- "unodered container::erase(iterator, iterator) called with an iterator not"
- " referring to this unodered container");
+ "unordered container::erase(iterator, iterator) called with an iterator not"
+ " referring to this container");
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
- "unodered container::erase(iterator, iterator) called with an iterator not"
- " referring to this unodered container");
+ "unordered container::erase(iterator, iterator) called with an iterator not"
+ " referring to this container");
#endif
for (const_iterator __p = __first; __first != __last; __p = __first)
{
@@ -2804,10 +2804,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*,
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP__HASH_TABLE
+#endif // _LIBCPP__HASH_TABLE
diff --git a/contrib/llvm-project/libcxx/include/__iterator/access.h b/contrib/llvm-project/libcxx/include/__iterator/access.h
new file mode 100644
index 000000000000..c0576b45902b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/access.h
@@ -0,0 +1,134 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ACCESS_H
+#define _LIBCPP___ITERATOR_ACCESS_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, size_t _Np>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp*
+begin(_Tp (&__array)[_Np])
+{
+ return __array;
+}
+
+template <class _Tp, size_t _Np>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp*
+end(_Tp (&__array)[_Np])
+{
+ return __array + _Np;
+}
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto
+begin(_Cp& __c) -> decltype(__c.begin())
+{
+ return __c.begin();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto
+begin(const _Cp& __c) -> decltype(__c.begin())
+{
+ return __c.begin();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto
+end(_Cp& __c) -> decltype(__c.end())
+{
+ return __c.end();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto
+end(const _Cp& __c) -> decltype(__c.end())
+{
+ return __c.end();
+}
+
+#if _LIBCPP_STD_VER > 11
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
+{
+ return _VSTD::begin(__c);
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
+{
+ return _VSTD::end(__c);
+}
+
+#endif
+
+
+#else // defined(_LIBCPP_CXX03_LANG)
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY
+typename _Cp::iterator
+begin(_Cp& __c)
+{
+ return __c.begin();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY
+typename _Cp::const_iterator
+begin(const _Cp& __c)
+{
+ return __c.begin();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY
+typename _Cp::iterator
+end(_Cp& __c)
+{
+ return __c.end();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY
+typename _Cp::const_iterator
+end(const _Cp& __c)
+{
+ return __c.end();
+}
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ACCESS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/advance.h b/contrib/llvm-project/libcxx/include/__iterator/advance.h
new file mode 100644
index 000000000000..47bce1ddfbe2
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/advance.h
@@ -0,0 +1,200 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ADVANCE_H
+#define _LIBCPP___ITERATOR_ADVANCE_H
+
+#include <__config>
+#include <__debug>
+#include <__function_like.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/move.h>
+#include <cstdlib>
+#include <concepts>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) {
+ for (; __n > 0; --__n)
+ ++__i;
+}
+
+template <class _BiDirIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) {
+ if (__n >= 0)
+ for (; __n > 0; --__n)
+ ++__i;
+ else
+ for (; __n < 0; ++__n)
+ --__i;
+}
+
+template <class _RandIter>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) {
+ __i += __n;
+}
+
+template <
+ class _InputIter, class _Distance,
+ class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())),
+ class = _EnableIf<is_integral<_IntegralDistance>::value> >
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
+void advance(_InputIter& __i, _Distance __orig_n) {
+ typedef typename iterator_traits<_InputIter>::difference_type _Difference;
+ _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n));
+ _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
+ "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
+ _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
+}
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+// [range.iter.op.advance]
+struct __advance_fn final : private __function_like {
+private:
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept {
+ return __a < 0 ? (__a <= __b) : (__a >= __b);
+ }
+
+ template <class _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) {
+ while (__n > 0) {
+ --__n;
+ ++__i;
+ }
+ }
+
+ template <class _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr void __advance_backward(_Ip& __i, iter_difference_t<_Ip> __n) {
+ while (__n < 0) {
+ ++__n;
+ --__i;
+ }
+ }
+
+public:
+ constexpr explicit __advance_fn(__tag __x) noexcept : __function_like(__x) {}
+
+ // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative.
+ template <input_or_output_iterator _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const {
+ _LIBCPP_ASSERT(__n >= 0 || bidirectional_iterator<_Ip>,
+ "If `n < 0`, then `bidirectional_iterator<I>` must be true.");
+
+ // If `I` models `random_access_iterator`, equivalent to `i += n`.
+ if constexpr (random_access_iterator<_Ip>) {
+ __i += __n;
+ return;
+ } else if constexpr (bidirectional_iterator<_Ip>) {
+ // Otherwise, if `n` is non-negative, increments `i` by `n`.
+ __advance_forward(__i, __n);
+ // Otherwise, decrements `i` by `-n`.
+ __advance_backward(__i, __n);
+ return;
+ } else {
+ // Otherwise, if `n` is non-negative, increments `i` by `n`.
+ __advance_forward(__i, __n);
+ return;
+ }
+ }
+
+ // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range.
+ template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()(_Ip& __i, _Sp __bound) const {
+ // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`.
+ if constexpr (assignable_from<_Ip&, _Sp>) {
+ __i = _VSTD::move(__bound);
+ }
+ // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`.
+ else if constexpr (sized_sentinel_for<_Sp, _Ip>) {
+ (*this)(__i, __bound - __i);
+ }
+ // Otherwise, while `bool(i != bound)` is true, increments `i`.
+ else {
+ while (__i != __bound) {
+ ++__i;
+ }
+ }
+ }
+
+ // Preconditions:
+ // * If `n > 0`, [i, bound) denotes a range.
+ // * If `n == 0`, [i, bound) or [bound, i) denotes a range.
+ // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`.
+ // Returns: `n - M`, where `M` is the difference between the the ending and starting position.
+ template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const {
+ _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),
+ "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");
+ // If `S` and `I` model `sized_sentinel_for<S, I>`:
+ if constexpr (sized_sentinel_for<_Sp, _Ip>) {
+ // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`.
+ if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) {
+ (*this)(__i, __bound);
+ return __n - __M;
+ }
+
+ // Otherwise, equivalent to `ranges::advance(i, n)`.
+ (*this)(__i, __n);
+ return 0;
+ } else {
+ // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at
+ // most `n` times.
+ while (__i != __bound && __n > 0) {
+ ++__i;
+ --__n;
+ }
+
+ // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times.
+ if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
+ while (__i != __bound && __n < 0) {
+ --__i;
+ ++__n;
+ }
+ }
+ return __n;
+ }
+
+ _LIBCPP_UNREACHABLE();
+ }
+};
+
+inline constexpr auto advance = __advance_fn(__function_like::__tag());
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ADVANCE_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/back_insert_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/back_insert_iterator.h
new file mode 100644
index 000000000000..f34cb863bc09
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/back_insert_iterator.h
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
+#define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__utility/move.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Container>
+class _LIBCPP_TEMPLATE_VIS back_insert_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<output_iterator_tag, void, void, void, void>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+protected:
+ _Container* container;
+public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _Container container_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_)
+ {container->push_back(__value_); return *this;}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_)
+ {container->push_back(_VSTD::move(__value_)); return *this;}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+back_insert_iterator<_Container>
+back_inserter(_Container& __x)
+{
+ return back_insert_iterator<_Container>(__x);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h
new file mode 100644
index 000000000000..fb01d8bd4b95
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/common_iterator.h
@@ -0,0 +1,301 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_COMMON_ITERATOR_H
+#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
+
+#include <__config>
+#include <__debug>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
+#include <concepts>
+#include <variant>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
+ requires (!same_as<_Iter, _Sent> && copyable<_Iter>)
+class common_iterator {
+ class __proxy {
+ friend common_iterator;
+
+ iter_value_t<_Iter> __value;
+ // We can move __x because the only caller verifies that __x is not a reference.
+ constexpr __proxy(iter_reference_t<_Iter>&& __x)
+ : __value(_VSTD::move(__x)) {}
+
+ public:
+ const iter_value_t<_Iter>* operator->() const {
+ return _VSTD::addressof(__value);
+ }
+ };
+
+ class __postfix_proxy {
+ friend common_iterator;
+
+ iter_value_t<_Iter> __value;
+ constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x)
+ : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {}
+
+ public:
+ constexpr static bool __valid_for_iter =
+ constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>> &&
+ move_constructible<iter_value_t<_Iter>>;
+
+ const iter_value_t<_Iter>& operator*() const {
+ return __value;
+ }
+ };
+
+public:
+ variant<_Iter, _Sent> __hold_;
+
+ common_iterator() requires default_initializable<_Iter> = default;
+
+ constexpr common_iterator(_Iter __i) : __hold_(in_place_type<_Iter>, _VSTD::move(__i)) {}
+ constexpr common_iterator(_Sent __s) : __hold_(in_place_type<_Sent>, _VSTD::move(__s)) {}
+
+ template<class _I2, class _S2>
+ requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent>
+ constexpr common_iterator(const common_iterator<_I2, _S2>& __other)
+ : __hold_([&]() -> variant<_Iter, _Sent> {
+ _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Constructed from valueless iterator.");
+ if (__other.__hold_.index() == 0)
+ return variant<_Iter, _Sent>{in_place_index<0>, _VSTD::__unchecked_get<0>(__other.__hold_)};
+ return variant<_Iter, _Sent>{in_place_index<1>, _VSTD::__unchecked_get<1>(__other.__hold_)};
+ }()) {}
+
+ template<class _I2, class _S2>
+ requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> &&
+ assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&>
+ common_iterator& operator=(const common_iterator<_I2, _S2>& __other) {
+ _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Assigned from valueless iterator.");
+
+ auto __idx = __hold_.index();
+ auto __other_idx = __other.__hold_.index();
+
+ // If they're the same index, just assign.
+ if (__idx == 0 && __other_idx == 0)
+ _VSTD::__unchecked_get<0>(__hold_) = _VSTD::__unchecked_get<0>(__other.__hold_);
+ else if (__idx == 1 && __other_idx == 1)
+ _VSTD::__unchecked_get<1>(__hold_) = _VSTD::__unchecked_get<1>(__other.__hold_);
+
+ // Otherwise replace with the oposite element.
+ else if (__other_idx == 1)
+ __hold_.template emplace<1>(_VSTD::__unchecked_get<1>(__other.__hold_));
+ else if (__other_idx == 0)
+ __hold_.template emplace<0>(_VSTD::__unchecked_get<0>(__other.__hold_));
+
+ return *this;
+ }
+
+ decltype(auto) operator*()
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_),
+ "Cannot dereference sentinel. Common iterator not holding an iterator.");
+ return *_VSTD::__unchecked_get<_Iter>(__hold_);
+ }
+
+ decltype(auto) operator*() const
+ requires __dereferenceable<const _Iter>
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_),
+ "Cannot dereference sentinel. Common iterator not holding an iterator.");
+ return *_VSTD::__unchecked_get<_Iter>(__hold_);
+ }
+
+ template<class _I2 = _Iter>
+ decltype(auto) operator->() const
+ requires indirectly_readable<const _I2> &&
+ (requires(const _I2& __i) { __i.operator->(); } ||
+ is_reference_v<iter_reference_t<_I2>> ||
+ constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_),
+ "Cannot dereference sentinel. Common iterator not holding an iterator.");
+
+ if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) {
+ return _VSTD::__unchecked_get<_Iter>(__hold_);
+ } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) {
+ auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_);
+ return _VSTD::addressof(__tmp);
+ } else {
+ return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_));
+ }
+ }
+
+ common_iterator& operator++() {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_),
+ "Cannot increment sentinel. Common iterator not holding an iterator.");
+ ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this;
+ }
+
+ decltype(auto) operator++(int) {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_),
+ "Cannot increment sentinel. Common iterator not holding an iterator.");
+
+ if constexpr (forward_iterator<_Iter>) {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } ||
+ !__postfix_proxy::__valid_for_iter) {
+ return _VSTD::__unchecked_get<_Iter>(__hold_)++;
+ } else {
+ __postfix_proxy __p(**this);
+ ++*this;
+ return __p;
+ }
+ }
+
+ template<class _I2, sentinel_for<_Iter> _S2>
+ requires sentinel_for<_Sent, _I2>
+ friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
+ _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() &&
+ !__y.__hold_.valueless_by_exception(),
+ "One or both common_iterators are valueless. (Cannot compare valueless iterators.)");
+
+ auto __x_index = __x.__hold_.index();
+ auto __y_index = __y.__hold_.index();
+
+ if (__x_index == __y_index)
+ return true;
+
+ if (__x_index == 0)
+ return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_);
+
+ return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_);
+ }
+
+ template<class _I2, sentinel_for<_Iter> _S2>
+ requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>
+ friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
+ _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() &&
+ !__y.__hold_.valueless_by_exception(),
+ "One or both common_iterators are valueless. (Cannot compare valueless iterators.)");
+
+ auto __x_index = __x.__hold_.index();
+ auto __y_index = __y.__hold_.index();
+
+ if (__x_index == 1 && __y_index == 1)
+ return true;
+
+ if (__x_index == 0 && __y_index == 0)
+ return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_);
+
+ if (__x_index == 0)
+ return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_);
+
+ return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_);
+ }
+
+ template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2>
+ requires sized_sentinel_for<_Sent, _I2>
+ friend iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
+ _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() &&
+ !__y.__hold_.valueless_by_exception(),
+ "One or both common_iterators are valueless. (Cannot subtract valueless iterators.)");
+
+ auto __x_index = __x.__hold_.index();
+ auto __y_index = __y.__hold_.index();
+
+ if (__x_index == 1 && __y_index == 1)
+ return 0;
+
+ if (__x_index == 0 && __y_index == 0)
+ return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_);
+
+ if (__x_index == 0)
+ return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_S2>(__y.__hold_);
+
+ return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_);
+ }
+
+ friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)
+ noexcept(noexcept(ranges::iter_move(declval<const _Iter&>())))
+ requires input_iterator<_Iter>
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_),
+ "Cannot iter_move a sentinel. Common iterator not holding an iterator.");
+ return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_));
+ }
+
+ template<indirectly_swappable<_Iter> _I2, class _S2>
+ friend void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y)
+ noexcept(noexcept(ranges::iter_swap(declval<const _Iter&>(), declval<const _I2&>())))
+ {
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_),
+ "Cannot swap __y with a sentinel. Common iterator (__x) not holding an iterator.");
+ _LIBCPP_ASSERT(holds_alternative<_Iter>(__y.__hold_),
+ "Cannot swap __x with a sentinel. Common iterator (__y) not holding an iterator.");
+ return ranges::iter_swap( _VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_Iter>(__y.__hold_));
+ }
+};
+
+template<class _Iter, class _Sent>
+struct incrementable_traits<common_iterator<_Iter, _Sent>> {
+ using difference_type = iter_difference_t<_Iter>;
+};
+
+template<class _Iter>
+concept __denotes_forward_iter =
+ requires { typename iterator_traits<_Iter>::iterator_category; } &&
+ derived_from<typename iterator_traits<_Iter>::iterator_category, forward_iterator_tag>;
+
+template<class _Iter, class _Sent>
+concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>& __a) {
+ __a.operator->();
+};
+
+template<class, class>
+struct __arrow_type_or_void {
+ using type = void;
+};
+
+template<class _Iter, class _Sent>
+ requires __common_iter_has_ptr_op<_Iter, _Sent>
+struct __arrow_type_or_void<_Iter, _Sent> {
+ using type = decltype(declval<const common_iterator<_Iter, _Sent>>().operator->());
+};
+
+template<class _Iter, class _Sent>
+struct iterator_traits<common_iterator<_Iter, _Sent>> {
+ using iterator_concept = _If<forward_iterator<_Iter>,
+ forward_iterator_tag,
+ input_iterator_tag>;
+ using iterator_category = _If<__denotes_forward_iter<_Iter>,
+ forward_iterator_tag,
+ input_iterator_tag>;
+ using pointer = typename __arrow_type_or_void<_Iter, _Sent>::type;
+ using value_type = iter_value_t<_Iter>;
+ using difference_type = iter_difference_t<_Iter>;
+ using reference = iter_reference_t<_Iter>;
+};
+
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/concepts.h b/contrib/llvm-project/libcxx/include/__iterator/concepts.h
new file mode 100644
index 000000000000..6eb4aef10528
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/concepts.h
@@ -0,0 +1,272 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_CONCEPTS_H
+#define _LIBCPP___ITERATOR_CONCEPTS_H
+
+#include <__config>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
+#include <__memory/pointer_traits.h>
+#include <__utility/forward.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format off
+
+// [iterator.concept.readable]
+template<class _In>
+concept __indirectly_readable_impl =
+ requires(const _In __i) {
+ typename iter_value_t<_In>;
+ typename iter_reference_t<_In>;
+ typename iter_rvalue_reference_t<_In>;
+ { *__i } -> same_as<iter_reference_t<_In>>;
+ { ranges::iter_move(__i) } -> same_as<iter_rvalue_reference_t<_In>>;
+ } &&
+ common_reference_with<iter_reference_t<_In>&&, iter_value_t<_In>&> &&
+ common_reference_with<iter_reference_t<_In>&&, iter_rvalue_reference_t<_In>&&> &&
+ common_reference_with<iter_rvalue_reference_t<_In>&&, const iter_value_t<_In>&>;
+
+template<class _In>
+concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>;
+
+template<indirectly_readable _Tp>
+using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>;
+
+// [iterator.concept.writable]
+template<class _Out, class _Tp>
+concept indirectly_writable =
+ requires(_Out&& __o, _Tp&& __t) {
+ *__o = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving
+ *_VSTD::forward<_Out>(__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving
+ const_cast<const iter_reference_t<_Out>&&>(*__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving
+ const_cast<const iter_reference_t<_Out>&&>(*_VSTD::forward<_Out>(__o)) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving
+ };
+
+// [iterator.concept.winc]
+template<class _Tp>
+concept __integer_like = integral<_Tp> && !same_as<_Tp, bool>;
+
+template<class _Tp>
+concept __signed_integer_like = signed_integral<_Tp>;
+
+template<class _Ip>
+concept weakly_incrementable =
+ movable<_Ip> &&
+ requires(_Ip __i) {
+ typename iter_difference_t<_Ip>;
+ requires __signed_integer_like<iter_difference_t<_Ip>>;
+ { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving
+ __i++; // not required to be equality-preserving
+ };
+
+// [iterator.concept.inc]
+template<class _Ip>
+concept incrementable =
+ regular<_Ip> &&
+ weakly_incrementable<_Ip> &&
+ requires(_Ip __i) {
+ { __i++ } -> same_as<_Ip>;
+ };
+
+// [iterator.concept.iterator]
+template<class _Ip>
+concept input_or_output_iterator =
+ requires(_Ip __i) {
+ { *__i } -> __referenceable;
+ } &&
+ weakly_incrementable<_Ip>;
+
+// [iterator.concept.sentinel]
+template<class _Sp, class _Ip>
+concept sentinel_for =
+ semiregular<_Sp> &&
+ input_or_output_iterator<_Ip> &&
+ __weakly_equality_comparable_with<_Sp, _Ip>;
+
+template<class, class>
+inline constexpr bool disable_sized_sentinel_for = false;
+
+template<class _Sp, class _Ip>
+concept sized_sentinel_for =
+ sentinel_for<_Sp, _Ip> &&
+ !disable_sized_sentinel_for<remove_cv_t<_Sp>, remove_cv_t<_Ip>> &&
+ requires(const _Ip& __i, const _Sp& __s) {
+ { __s - __i } -> same_as<iter_difference_t<_Ip>>;
+ { __i - __s } -> same_as<iter_difference_t<_Ip>>;
+ };
+
+// [iterator.concept.input]
+template<class _Ip>
+concept input_iterator =
+ input_or_output_iterator<_Ip> &&
+ indirectly_readable<_Ip> &&
+ requires { typename _ITER_CONCEPT<_Ip>; } &&
+ derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>;
+
+// [iterator.concept.output]
+template<class _Ip, class _Tp>
+concept output_iterator =
+ input_or_output_iterator<_Ip> &&
+ indirectly_writable<_Ip, _Tp> &&
+ requires (_Ip __it, _Tp&& __t) {
+ *__it++ = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving
+ };
+
+// [iterator.concept.forward]
+template<class _Ip>
+concept forward_iterator =
+ input_iterator<_Ip> &&
+ derived_from<_ITER_CONCEPT<_Ip>, forward_iterator_tag> &&
+ incrementable<_Ip> &&
+ sentinel_for<_Ip, _Ip>;
+
+// [iterator.concept.bidir]
+template<class _Ip>
+concept bidirectional_iterator =
+ forward_iterator<_Ip> &&
+ derived_from<_ITER_CONCEPT<_Ip>, bidirectional_iterator_tag> &&
+ requires(_Ip __i) {
+ { --__i } -> same_as<_Ip&>;
+ { __i-- } -> same_as<_Ip>;
+ };
+
+template<class _Ip>
+concept random_access_iterator =
+ bidirectional_iterator<_Ip> &&
+ derived_from<_ITER_CONCEPT<_Ip>, random_access_iterator_tag> &&
+ totally_ordered<_Ip> &&
+ sized_sentinel_for<_Ip, _Ip> &&
+ requires(_Ip __i, const _Ip __j, const iter_difference_t<_Ip> __n) {
+ { __i += __n } -> same_as<_Ip&>;
+ { __j + __n } -> same_as<_Ip>;
+ { __n + __j } -> same_as<_Ip>;
+ { __i -= __n } -> same_as<_Ip&>;
+ { __j - __n } -> same_as<_Ip>;
+ { __j[__n] } -> same_as<iter_reference_t<_Ip>>;
+ };
+
+template<class _Ip>
+concept contiguous_iterator =
+ random_access_iterator<_Ip> &&
+ derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> &&
+ is_lvalue_reference_v<iter_reference_t<_Ip>> &&
+ same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>> &&
+ (is_pointer_v<_Ip> || requires { sizeof(__pointer_traits_element_type<_Ip>); }) &&
+ requires(const _Ip& __i) {
+ { _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>;
+ };
+
+template<class _Ip>
+concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip __i) { __i.operator->(); });
+
+// [indirectcallable.indirectinvocable]
+template<class _Fp, class _It>
+concept indirectly_unary_invocable =
+ indirectly_readable<_It> &&
+ copy_constructible<_Fp> &&
+ invocable<_Fp&, iter_value_t<_It>&> &&
+ invocable<_Fp&, iter_reference_t<_It>> &&
+ invocable<_Fp&, iter_common_reference_t<_It>> &&
+ common_reference_with<
+ invoke_result_t<_Fp&, iter_value_t<_It>&>,
+ invoke_result_t<_Fp&, iter_reference_t<_It>>>;
+
+template<class _Fp, class _It>
+concept indirectly_regular_unary_invocable =
+ indirectly_readable<_It> &&
+ copy_constructible<_Fp> &&
+ regular_invocable<_Fp&, iter_value_t<_It>&> &&
+ regular_invocable<_Fp&, iter_reference_t<_It>> &&
+ regular_invocable<_Fp&, iter_common_reference_t<_It>> &&
+ common_reference_with<
+ invoke_result_t<_Fp&, iter_value_t<_It>&>,
+ invoke_result_t<_Fp&, iter_reference_t<_It>>>;
+
+template<class _Fp, class _It>
+concept indirect_unary_predicate =
+ indirectly_readable<_It> &&
+ copy_constructible<_Fp> &&
+ predicate<_Fp&, iter_value_t<_It>&> &&
+ predicate<_Fp&, iter_reference_t<_It>> &&
+ predicate<_Fp&, iter_common_reference_t<_It>>;
+
+template<class _Fp, class _It1, class _It2>
+concept indirect_binary_predicate =
+ indirectly_readable<_It1> && indirectly_readable<_It2> &&
+ copy_constructible<_Fp> &&
+ predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
+ predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
+ predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
+ predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> &&
+ predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>;
+
+template<class _Fp, class _It1, class _It2 = _It1>
+concept indirect_equivalence_relation =
+ indirectly_readable<_It1> && indirectly_readable<_It2> &&
+ copy_constructible<_Fp> &&
+ equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
+ equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
+ equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
+ equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> &&
+ equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>;
+
+template<class _Fp, class _It1, class _It2 = _It1>
+concept indirect_strict_weak_order =
+ indirectly_readable<_It1> && indirectly_readable<_It2> &&
+ copy_constructible<_Fp> &&
+ strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
+ strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
+ strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
+ strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> &&
+ strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>;
+
+template<class _Fp, class... _Its>
+ requires (indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...>
+using indirect_result_t = invoke_result_t<_Fp, iter_reference_t<_Its>...>;
+
+template<class _In, class _Out>
+concept indirectly_movable =
+ indirectly_readable<_In> &&
+ indirectly_writable<_Out, iter_rvalue_reference_t<_In>>;
+
+template<class _In, class _Out>
+concept indirectly_movable_storable =
+ indirectly_movable<_In, _Out> &&
+ indirectly_writable<_Out, iter_value_t<_In>> &&
+ movable<iter_value_t<_In>> &&
+ constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> &&
+ assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>;
+
+// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle
+// (both iter_swap and indirectly_swappable require indirectly_readable).
+
+// clang-format on
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_CONCEPTS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h
new file mode 100644
index 000000000000..7136aaf02584
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/counted_iterator.h
@@ -0,0 +1,306 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
+#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
+
+#include <__config>
+#include <__debug>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
+#include <__memory/pointer_traits.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+template<class>
+struct __counted_iterator_concept {};
+
+template<class _Iter>
+ requires requires { typename _Iter::iterator_concept; }
+struct __counted_iterator_concept<_Iter> {
+ using iterator_concept = typename _Iter::iterator_concept;
+};
+
+template<class>
+struct __counted_iterator_category {};
+
+template<class _Iter>
+ requires requires { typename _Iter::iterator_category; }
+struct __counted_iterator_category<_Iter> {
+ using iterator_category = typename _Iter::iterator_category;
+};
+
+template<class>
+struct __counted_iterator_value_type {};
+
+template<indirectly_readable _Iter>
+struct __counted_iterator_value_type<_Iter> {
+ using value_type = iter_value_t<_Iter>;
+};
+
+template<input_or_output_iterator _Iter>
+class counted_iterator
+ : public __counted_iterator_concept<_Iter>
+ , public __counted_iterator_category<_Iter>
+ , public __counted_iterator_value_type<_Iter>
+{
+public:
+ [[no_unique_address]] _Iter __current_ = _Iter();
+ iter_difference_t<_Iter> __count_ = 0;
+
+ using iterator_type = _Iter;
+ using difference_type = iter_difference_t<_Iter>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator() requires default_initializable<_Iter> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator(_Iter __iter, iter_difference_t<_Iter> __n)
+ : __current_(_VSTD::move(__iter)), __count_(__n) {
+ _LIBCPP_ASSERT(__n >= 0, "__n must not be negative.");
+ }
+
+ template<class _I2>
+ requires convertible_to<const _I2&, _Iter>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator(const counted_iterator<_I2>& __other)
+ : __current_(__other.__current_), __count_(__other.__count_) {}
+
+ template<class _I2>
+ requires assignable_from<_Iter&, const _I2&>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator& operator=(const counted_iterator<_I2>& __other) {
+ __current_ = __other.__current_;
+ __count_ = __other.__count_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr const _Iter& base() const& { return __current_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Iter base() && { return _VSTD::move(__current_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator*() {
+ _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end.");
+ return *__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator*() const
+ requires __dereferenceable<const _Iter>
+ {
+ _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end.");
+ return *__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator->() const noexcept
+ requires contiguous_iterator<_Iter>
+ {
+ return _VSTD::to_address(__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator& operator++() {
+ _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end.");
+ ++__current_;
+ --__count_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ decltype(auto) operator++(int) {
+ _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end.");
+ --__count_;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try { return __current_++; }
+ catch(...) { ++__count_; throw; }
+#else
+ return __current_++;
+#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator operator++(int)
+ requires forward_iterator<_Iter>
+ {
+ _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end.");
+ counted_iterator __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator& operator--()
+ requires bidirectional_iterator<_Iter>
+ {
+ --__current_;
+ ++__count_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator operator--(int)
+ requires bidirectional_iterator<_Iter>
+ {
+ counted_iterator __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator operator+(iter_difference_t<_Iter> __n) const
+ requires random_access_iterator<_Iter>
+ {
+ return counted_iterator(__current_ + __n, __count_ - __n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr counted_iterator operator+(
+ iter_difference_t<_Iter> __n, const counted_iterator& __x)
+ requires random_access_iterator<_Iter>
+ {
+ return __x + __n;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator& operator+=(iter_difference_t<_Iter> __n)
+ requires random_access_iterator<_Iter>
+ {
+ _LIBCPP_ASSERT(__n <= __count_, "Cannot advance iterator past end.");
+ __current_ += __n;
+ __count_ -= __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator operator-(iter_difference_t<_Iter> __n) const
+ requires random_access_iterator<_Iter>
+ {
+ return counted_iterator(__current_ - __n, __count_ + __n);
+ }
+
+ template<common_with<_Iter> _I2>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_I2> operator-(
+ const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)
+ {
+ return __rhs.__count_ - __lhs.__count_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_Iter> operator-(
+ const counted_iterator& __lhs, default_sentinel_t)
+ {
+ return -__lhs.__count_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_difference_t<_Iter> operator-(
+ default_sentinel_t, const counted_iterator& __rhs)
+ {
+ return __rhs.__count_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr counted_iterator& operator-=(iter_difference_t<_Iter> __n)
+ requires random_access_iterator<_Iter>
+ {
+ _LIBCPP_ASSERT(-__n <= __count_, "Attempt to subtract too large of a size: "
+ "counted_iterator would be decremented before the "
+ "first element of its range.");
+ __current_ -= __n;
+ __count_ += __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const
+ requires random_access_iterator<_Iter>
+ {
+ _LIBCPP_ASSERT(__n < __count_, "Subscript argument must be less than size.");
+ return __current_[__n];
+ }
+
+ template<common_with<_Iter> _I2>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(
+ const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)
+ {
+ return __lhs.__count_ == __rhs.__count_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(
+ const counted_iterator& __lhs, default_sentinel_t)
+ {
+ return __lhs.__count_ == 0;
+ }
+
+ template<common_with<_Iter> _I2>
+ friend constexpr strong_ordering operator<=>(
+ const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)
+ {
+ return __rhs.__count_ <=> __lhs.__count_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const counted_iterator& __i)
+ noexcept(noexcept(ranges::iter_move(__i.__current_)))
+ requires input_iterator<_Iter>
+ {
+ _LIBCPP_ASSERT(__i.__count_ > 0, "Iterator must not be past end of range.");
+ return ranges::iter_move(__i.__current_);
+ }
+
+ template<indirectly_swappable<_Iter> _I2>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr void iter_swap(const counted_iterator& __x, const counted_iterator<_I2>& __y)
+ noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
+ {
+ _LIBCPP_ASSERT(__x.__count_ > 0 && __y.__count_ > 0,
+ "Iterators must not be past end of range.");
+ return ranges::iter_swap(__x.__current_, __y.__current_);
+ }
+};
+
+template<input_iterator _Iter>
+ requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>>
+struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> {
+ using pointer = conditional_t<contiguous_iterator<_Iter>,
+ add_pointer_t<iter_reference_t<_Iter>>, void>;
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/data.h b/contrib/llvm-project/libcxx/include/__iterator/data.h
new file mode 100644
index 000000000000..cd8e37b96b6e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/data.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_DATA_H
+#define _LIBCPP___ITERATOR_DATA_H
+
+#include <__config>
+#include <cstddef>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Cont> constexpr
+_LIBCPP_INLINE_VISIBILITY
+auto data(_Cont& __c)
+_NOEXCEPT_(noexcept(__c.data()))
+-> decltype (__c.data())
+{ return __c.data(); }
+
+template <class _Cont> constexpr
+_LIBCPP_INLINE_VISIBILITY
+auto data(const _Cont& __c)
+_NOEXCEPT_(noexcept(__c.data()))
+-> decltype (__c.data())
+{ return __c.data(); }
+
+template <class _Tp, size_t _Sz>
+_LIBCPP_INLINE_VISIBILITY
+constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
+
+template <class _Ep>
+_LIBCPP_INLINE_VISIBILITY
+constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_DATA_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h b/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h
new file mode 100644
index 000000000000..934a56fd9e29
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/default_sentinel.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H
+#define _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+struct default_sentinel_t { };
+inline constexpr default_sentinel_t default_sentinel{};
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/distance.h b/contrib/llvm-project/libcxx/include/__iterator/distance.h
new file mode 100644
index 000000000000..33e4af84d36e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/distance.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_DISTANCE_H
+#define _LIBCPP___ITERATOR_DISTANCE_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+typename iterator_traits<_InputIter>::difference_type
+__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
+{
+ typename iterator_traits<_InputIter>::difference_type __r(0);
+ for (; __first != __last; ++__first)
+ ++__r;
+ return __r;
+}
+
+template <class _RandIter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+typename iterator_traits<_RandIter>::difference_type
+__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
+{
+ return __last - __first;
+}
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+typename iterator_traits<_InputIter>::difference_type
+distance(_InputIter __first, _InputIter __last)
+{
+ return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_DISTANCE_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/empty.h b/contrib/llvm-project/libcxx/include/__iterator/empty.h
new file mode 100644
index 000000000000..4dd59f5cccbd
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/empty.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_EMPTY_H
+#define _LIBCPP___ITERATOR_EMPTY_H
+
+#include <__config>
+#include <cstddef>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Cont>
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+constexpr auto empty(const _Cont& __c)
+_NOEXCEPT_(noexcept(__c.empty()))
+-> decltype (__c.empty())
+{ return __c.empty(); }
+
+template <class _Tp, size_t _Sz>
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
+
+template <class _Ep>
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_EMPTY_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/erase_if_container.h b/contrib/llvm-project/libcxx/include/__iterator/erase_if_container.h
new file mode 100644
index 000000000000..a5dfd0720535
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/erase_if_container.h
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H
+#define _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Container, class _Predicate>
+_LIBCPP_HIDE_FROM_ABI
+typename _Container::size_type
+__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) {
+ typename _Container::size_type __old_size = __c.size();
+
+ const typename _Container::iterator __last = __c.end();
+ for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) {
+ if (__pred(*__iter))
+ __iter = __c.erase(__iter);
+ else
+ ++__iter;
+ }
+
+ return __old_size - __c.size();
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/front_insert_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/front_insert_iterator.h
new file mode 100644
index 000000000000..0421dd5c4b21
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/front_insert_iterator.h
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H
+#define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__utility/move.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Container>
+class _LIBCPP_TEMPLATE_VIS front_insert_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<output_iterator_tag, void, void, void, void>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+protected:
+ _Container* container;
+public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _Container container_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_)
+ {container->push_front(__value_); return *this;}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_)
+ {container->push_front(_VSTD::move(__value_)); return *this;}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+front_insert_iterator<_Container>
+front_inserter(_Container& __x)
+{
+ return front_insert_iterator<_Container>(__x);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h
new file mode 100644
index 000000000000..5a433982ba27
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/incrementable_traits.h
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
+#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
+
+#include <__config>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// [incrementable.traits]
+template<class> struct incrementable_traits {};
+
+template<class _Tp>
+requires is_object_v<_Tp>
+struct incrementable_traits<_Tp*> {
+ using difference_type = ptrdiff_t;
+};
+
+template<class _Ip>
+struct incrementable_traits<const _Ip> : incrementable_traits<_Ip> {};
+
+template<class _Tp>
+concept __has_member_difference_type = requires { typename _Tp::difference_type; };
+
+template<__has_member_difference_type _Tp>
+struct incrementable_traits<_Tp> {
+ using difference_type = typename _Tp::difference_type;
+};
+
+template<class _Tp>
+concept __has_integral_minus =
+ requires(const _Tp& __x, const _Tp& __y) {
+ { __x - __y } -> integral;
+ };
+
+template<__has_integral_minus _Tp>
+requires (!__has_member_difference_type<_Tp>)
+struct incrementable_traits<_Tp> {
+ using difference_type = make_signed_t<decltype(declval<_Tp>() - declval<_Tp>())>;
+};
+
+template <class>
+struct iterator_traits;
+
+// Let `RI` be `remove_cvref_t<I>`. The type `iter_difference_t<I>` denotes
+// `incrementable_traits<RI>::difference_type` if `iterator_traits<RI>` names a specialization
+// generated from the primary template, and `iterator_traits<RI>::difference_type` otherwise.
+template <class _Ip>
+using iter_difference_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
+ incrementable_traits<remove_cvref_t<_Ip> >,
+ iterator_traits<remove_cvref_t<_Ip> > >::difference_type;
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h
new file mode 100644
index 000000000000..265814182475
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/insert_iterator.h
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_INSERT_ITERATOR_H
+#define _LIBCPP___ITERATOR_INSERT_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__utility/move.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Container>
+class _LIBCPP_TEMPLATE_VIS insert_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<output_iterator_tag, void, void, void, void>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+protected:
+ _Container* container;
+ typename _Container::iterator iter; // FIXME: `ranges::iterator_t<Container>` in C++20 mode
+public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _Container container_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i)
+ : container(_VSTD::addressof(__x)), iter(__i) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_)
+ {iter = container->insert(iter, __value_); ++iter; return *this;}
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_)
+ {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+insert_iterator<_Container>
+inserter(_Container& __x, typename _Container::iterator __i)
+{
+ return insert_iterator<_Container>(__x, __i);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/istream_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/istream_iterator.h
new file mode 100644
index 000000000000..f39faa6d590b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/istream_iterator.h
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
+#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <iosfwd> // for forward declarations of char_traits and basic_istream
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp, class _CharT = char,
+ class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
+class _LIBCPP_TEMPLATE_VIS istream_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+public:
+ typedef input_iterator_tag iterator_category;
+ typedef _Tp value_type;
+ typedef _Distance difference_type;
+ typedef const _Tp* pointer;
+ typedef const _Tp& reference;
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef basic_istream<_CharT,_Traits> istream_type;
+private:
+ istream_type* __in_stream_;
+ _Tp __value_;
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
+ _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
+ {
+ if (!(*__in_stream_ >> __value_))
+ __in_stream_ = nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
+ _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));}
+ _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
+ {
+ if (!(*__in_stream_ >> __value_))
+ __in_stream_ = nullptr;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)
+ {istream_iterator __t(*this); ++(*this); return __t;}
+
+ template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool
+ operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
+ const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
+
+ template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
+ friend _LIBCPP_INLINE_VISIBILITY
+ bool
+ operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
+ const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
+};
+
+template <class _Tp, class _CharT, class _Traits, class _Distance>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
+ const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
+{
+ return __x.__in_stream_ == __y.__in_stream_;
+}
+
+template <class _Tp, class _CharT, class _Traits, class _Distance>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
+ const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
+{
+ return !(__x == __y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/istreambuf_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/istreambuf_iterator.h
new file mode 100644
index 000000000000..119698d54ce9
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/istreambuf_iterator.h
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
+#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <iosfwd> // for forward declaration of basic_streambuf
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template<class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS istreambuf_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<input_iterator_tag, _CharT,
+ typename _Traits::off_type, _CharT*,
+ _CharT>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+public:
+ typedef input_iterator_tag iterator_category;
+ typedef _CharT value_type;
+ typedef typename _Traits::off_type difference_type;
+ typedef _CharT* pointer;
+ typedef _CharT reference;
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename _Traits::int_type int_type;
+ typedef basic_streambuf<_CharT,_Traits> streambuf_type;
+ typedef basic_istream<_CharT,_Traits> istream_type;
+private:
+ mutable streambuf_type* __sbuf_;
+
+ class __proxy
+ {
+ char_type __keep_;
+ streambuf_type* __sbuf_;
+ _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)
+ : __keep_(__c), __sbuf_(__s) {}
+ friend class istreambuf_iterator;
+ public:
+ _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;}
+ };
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __test_for_eof() const
+ {
+ if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
+ __sbuf_ = nullptr;
+ return __sbuf_ == nullptr;
+ }
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
+ : __sbuf_(__s.rdbuf()) {}
+ _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
+ : __sbuf_(__s) {}
+ _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT
+ : __sbuf_(__p.__sbuf_) {}
+
+ _LIBCPP_INLINE_VISIBILITY char_type operator*() const
+ {return static_cast<char_type>(__sbuf_->sgetc());}
+ _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++()
+ {
+ __sbuf_->sbumpc();
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY __proxy operator++(int)
+ {
+ return __proxy(__sbuf_->sbumpc(), __sbuf_);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
+ {return __test_for_eof() == __b.__test_for_eof();}
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
+ const istreambuf_iterator<_CharT,_Traits>& __b)
+ {return __a.equal(__b);}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
+ const istreambuf_iterator<_CharT,_Traits>& __b)
+ {return !__a.equal(__b);}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/iter_move.h b/contrib/llvm-project/libcxx/include/__iterator/iter_move.h
new file mode 100644
index 000000000000..5540799e197f
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/iter_move.h
@@ -0,0 +1,91 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ITER_MOVE_H
+#define _LIBCPP___ITERATOR_ITER_MOVE_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <__utility/forward.h>
+#include <concepts> // __class_or_enum
+#include <type_traits>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges::__iter_move {
+void iter_move();
+
+template<class _Ip>
+concept __unqualified_iter_move = requires(_Ip&& __i) {
+ iter_move(_VSTD::forward<_Ip>(__i));
+};
+
+// [iterator.cust.move]/1
+// The name ranges::iter_move denotes a customization point object.
+// The expression ranges::iter_move(E) for a subexpression E is
+// expression-equivalent to:
+struct __fn {
+ // [iterator.cust.move]/1.1
+ // iter_move(E), if E has class or enumeration type and iter_move(E) is a
+ // well-formed expression when treated as an unevaluated operand, [...]
+ template<class _Ip>
+ requires __class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
+ noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i))))
+ {
+ return iter_move(_VSTD::forward<_Ip>(__i));
+ }
+
+ // [iterator.cust.move]/1.2
+ // Otherwise, if the expression *E is well-formed:
+ // 1.2.1 if *E is an lvalue, std::move(*E);
+ // 1.2.2 otherwise, *E.
+ template<class _Ip>
+ requires (!(__class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>)) &&
+ requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
+ noexcept(noexcept(*_VSTD::forward<_Ip>(__i)))
+ {
+ if constexpr (is_lvalue_reference_v<decltype(*_VSTD::forward<_Ip>(__i))>) {
+ return _VSTD::move(*_VSTD::forward<_Ip>(__i));
+ } else {
+ return *_VSTD::forward<_Ip>(__i);
+ }
+ }
+
+ // [iterator.cust.move]/1.3
+ // Otherwise, ranges::iter_move(E) is ill-formed.
+};
+} // namespace ranges::__iter_move
+
+namespace ranges::inline __cpo {
+ inline constexpr auto iter_move = __iter_move::__fn{};
+}
+
+template<__dereferenceable _Tp>
+requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; }
+using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
+
+#endif // !_LIBCPP_HAS_NO_RANGES
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ITER_MOVE_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h b/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h
new file mode 100644
index 000000000000..d70da09b4ab8
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/iter_swap.h
@@ -0,0 +1,107 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___ITERATOR_ITER_SWAP_H
+#define _LIBCPP___ITERATOR_ITER_SWAP_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
+#include <__ranges/access.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+namespace __iter_swap {
+ template<class _I1, class _I2>
+ void iter_swap(_I1, _I2) = delete;
+
+ template<class _T1, class _T2>
+ concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) {
+ iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
+ };
+
+ template<class _T1, class _T2>
+ concept __readable_swappable =
+ indirectly_readable<_T1> && indirectly_readable<_T2> &&
+ swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>;
+
+ struct __fn {
+ template <class _T1, class _T2>
+ requires __unqualified_iter_swap<_T1, _T2>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()(_T1&& __x, _T2&& __y) const
+ noexcept(noexcept(iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y))))
+ {
+ (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
+ }
+
+ template <class _T1, class _T2>
+ requires (!__unqualified_iter_swap<_T1, _T2>) &&
+ __readable_swappable<_T1, _T2>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()(_T1&& __x, _T2&& __y) const
+ noexcept(noexcept(ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y))))
+ {
+ ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y));
+ }
+
+ template <class _T1, class _T2>
+ requires (!__unqualified_iter_swap<_T1, _T2> &&
+ !__readable_swappable<_T1, _T2>) &&
+ indirectly_movable_storable<_T1, _T2> &&
+ indirectly_movable_storable<_T2, _T1>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator()(_T1&& __x, _T2&& __y) const
+ noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) &&
+ noexcept(*__y = ranges::iter_move(__x)) &&
+ noexcept(*_VSTD::forward<_T1>(__x) = declval<iter_value_t<_T2>>()))
+ {
+ iter_value_t<_T2> __old(ranges::iter_move(__y));
+ *__y = ranges::iter_move(__x);
+ *_VSTD::forward<_T1>(__x) = _VSTD::move(__old);
+ }
+ };
+} // end namespace __iter_swap
+
+inline namespace __cpo {
+ inline constexpr auto iter_swap = __iter_swap::__fn{};
+} // namespace __cpo
+
+} // namespace ranges
+
+template<class _I1, class _I2 = _I1>
+concept indirectly_swappable =
+ indirectly_readable<_I1> && indirectly_readable<_I2> &&
+ requires(const _I1 __i1, const _I2 __i2) {
+ ranges::iter_swap(__i1, __i1);
+ ranges::iter_swap(__i2, __i2);
+ ranges::iter_swap(__i1, __i2);
+ ranges::iter_swap(__i2, __i1);
+ };
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ITER_SWAP_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/iterator.h b/contrib/llvm-project/libcxx/include/__iterator/iterator.h
new file mode 100644
index 000000000000..dfd481e35712
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/iterator.h
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ITERATOR_H
+#define _LIBCPP___ITERATOR_ITERATOR_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Category, class _Tp, class _Distance = ptrdiff_t,
+ class _Pointer = _Tp*, class _Reference = _Tp&>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator
+{
+ typedef _Tp value_type;
+ typedef _Distance difference_type;
+ typedef _Pointer pointer;
+ typedef _Reference reference;
+ typedef _Category iterator_category;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h
new file mode 100644
index 000000000000..5275705c117c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/iterator_traits.h
@@ -0,0 +1,500 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
+#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
+
+#include <__config>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/readable_traits.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+template <class _Tp>
+using __with_reference = _Tp&;
+
+template <class _Tp>
+concept __referenceable = requires {
+ typename __with_reference<_Tp>;
+};
+
+template <class _Tp>
+concept __dereferenceable = requires(_Tp& __t) {
+ { *__t } -> __referenceable; // not required to be equality-preserving
+};
+
+// [iterator.traits]
+template<__dereferenceable _Tp>
+using iter_reference_t = decltype(*declval<_Tp&>());
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+template <class _Iter>
+struct _LIBCPP_TEMPLATE_VIS iterator_traits;
+
+struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};
+struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};
+struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {};
+struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};
+struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};
+#if _LIBCPP_STD_VER > 17
+struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {};
+#endif
+
+template <class _Iter>
+struct __iter_traits_cache {
+ using type = _If<
+ __is_primary_template<iterator_traits<_Iter> >::value,
+ _Iter,
+ iterator_traits<_Iter>
+ >;
+};
+template <class _Iter>
+using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type;
+
+struct __iter_concept_concept_test {
+ template <class _Iter>
+ using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept;
+};
+struct __iter_concept_category_test {
+ template <class _Iter>
+ using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category;
+};
+struct __iter_concept_random_fallback {
+ template <class _Iter>
+ using _Apply = _EnableIf<
+ __is_primary_template<iterator_traits<_Iter> >::value,
+ random_access_iterator_tag
+ >;
+};
+
+template <class _Iter, class _Tester> struct __test_iter_concept
+ : _IsValidExpansion<_Tester::template _Apply, _Iter>,
+ _Tester
+{
+};
+
+template <class _Iter>
+struct __iter_concept_cache {
+ using type = _Or<
+ __test_iter_concept<_Iter, __iter_concept_concept_test>,
+ __test_iter_concept<_Iter, __iter_concept_category_test>,
+ __test_iter_concept<_Iter, __iter_concept_random_fallback>
+ >;
+};
+
+template <class _Iter>
+using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;
+
+
+template <class _Tp>
+struct __has_iterator_typedefs
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
+ typename __void_t<typename _Up::difference_type>::type* = 0,
+ typename __void_t<typename _Up::value_type>::type* = 0,
+ typename __void_t<typename _Up::reference>::type* = 0,
+ typename __void_t<typename _Up::pointer>::type* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
+};
+
+
+template <class _Tp>
+struct __has_iterator_category
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::iterator_category* = nullptr);
+public:
+ static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
+};
+
+template <class _Tp>
+struct __has_iterator_concept
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::iterator_concept* = nullptr);
+public:
+ static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
+};
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables,
+// so they've been banished to a namespace that makes it obvious they have a niche use-case.
+namespace __iterator_traits_detail {
+template<class _Ip>
+concept __cpp17_iterator =
+ requires(_Ip __i) {
+ { *__i } -> __referenceable;
+ { ++__i } -> same_as<_Ip&>;
+ { *__i++ } -> __referenceable;
+ } &&
+ copyable<_Ip>;
+
+template<class _Ip>
+concept __cpp17_input_iterator =
+ __cpp17_iterator<_Ip> &&
+ equality_comparable<_Ip> &&
+ requires(_Ip __i) {
+ typename incrementable_traits<_Ip>::difference_type;
+ typename indirectly_readable_traits<_Ip>::value_type;
+ typename common_reference_t<iter_reference_t<_Ip>&&,
+ typename indirectly_readable_traits<_Ip>::value_type&>;
+ typename common_reference_t<decltype(*__i++)&&,
+ typename indirectly_readable_traits<_Ip>::value_type&>;
+ requires signed_integral<typename incrementable_traits<_Ip>::difference_type>;
+ };
+
+template<class _Ip>
+concept __cpp17_forward_iterator =
+ __cpp17_input_iterator<_Ip> &&
+ constructible_from<_Ip> &&
+ is_lvalue_reference_v<iter_reference_t<_Ip>> &&
+ same_as<remove_cvref_t<iter_reference_t<_Ip>>,
+ typename indirectly_readable_traits<_Ip>::value_type> &&
+ requires(_Ip __i) {
+ { __i++ } -> convertible_to<_Ip const&>;
+ { *__i++ } -> same_as<iter_reference_t<_Ip>>;
+ };
+
+template<class _Ip>
+concept __cpp17_bidirectional_iterator =
+ __cpp17_forward_iterator<_Ip> &&
+ requires(_Ip __i) {
+ { --__i } -> same_as<_Ip&>;
+ { __i-- } -> convertible_to<_Ip const&>;
+ { *__i-- } -> same_as<iter_reference_t<_Ip>>;
+ };
+
+template<class _Ip>
+concept __cpp17_random_access_iterator =
+ __cpp17_bidirectional_iterator<_Ip> &&
+ totally_ordered<_Ip> &&
+ requires(_Ip __i, typename incrementable_traits<_Ip>::difference_type __n) {
+ { __i += __n } -> same_as<_Ip&>;
+ { __i -= __n } -> same_as<_Ip&>;
+ { __i + __n } -> same_as<_Ip>;
+ { __n + __i } -> same_as<_Ip>;
+ { __i - __n } -> same_as<_Ip>;
+ { __i - __i } -> same_as<decltype(__n)>;
+ { __i[__n] } -> convertible_to<iter_reference_t<_Ip>>;
+ };
+} // namespace __iterator_traits_detail
+
+template<class _Ip>
+concept __has_member_reference = requires { typename _Ip::reference; };
+
+template<class _Ip>
+concept __has_member_pointer = requires { typename _Ip::pointer; };
+
+template<class _Ip>
+concept __has_member_iterator_category = requires { typename _Ip::iterator_category; };
+
+template<class _Ip>
+concept __specifies_members = requires {
+ typename _Ip::value_type;
+ typename _Ip::difference_type;
+ requires __has_member_reference<_Ip>;
+ requires __has_member_iterator_category<_Ip>;
+ };
+
+template<class>
+struct __iterator_traits_member_pointer_or_void {
+ using type = void;
+};
+
+template<__has_member_pointer _Tp>
+struct __iterator_traits_member_pointer_or_void<_Tp> {
+ using type = typename _Tp::pointer;
+};
+
+template<class _Tp>
+concept __cpp17_iterator_missing_members =
+ !__specifies_members<_Tp> &&
+ __iterator_traits_detail::__cpp17_iterator<_Tp>;
+
+template<class _Tp>
+concept __cpp17_input_iterator_missing_members =
+ __cpp17_iterator_missing_members<_Tp> &&
+ __iterator_traits_detail::__cpp17_input_iterator<_Tp>;
+
+// Otherwise, `pointer` names `void`.
+template<class>
+struct __iterator_traits_member_pointer_or_arrow_or_void { using type = void; };
+
+// [iterator.traits]/3.2.1
+// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type.
+template<__has_member_pointer _Ip>
+struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typename _Ip::pointer; };
+
+// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that
+// type.
+template<class _Ip>
+ requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
+struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
+ using type = decltype(declval<_Ip&>().operator->());
+};
+
+// Otherwise, `reference` names `iter-reference-t<I>`.
+template<class _Ip>
+struct __iterator_traits_member_reference { using type = iter_reference_t<_Ip>; };
+
+// [iterator.traits]/3.2.2
+// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type.
+template<__has_member_reference _Ip>
+struct __iterator_traits_member_reference<_Ip> { using type = typename _Ip::reference; };
+
+// [iterator.traits]/3.2.3.4
+// input_iterator_tag
+template<class _Ip>
+struct __deduce_iterator_category {
+ using type = input_iterator_tag;
+};
+
+// [iterator.traits]/3.2.3.1
+// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise
+template<__iterator_traits_detail::__cpp17_random_access_iterator _Ip>
+struct __deduce_iterator_category<_Ip> {
+ using type = random_access_iterator_tag;
+};
+
+// [iterator.traits]/3.2.3.2
+// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise
+template<__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip>
+struct __deduce_iterator_category<_Ip> {
+ using type = bidirectional_iterator_tag;
+};
+
+// [iterator.traits]/3.2.3.3
+// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise
+template<__iterator_traits_detail::__cpp17_forward_iterator _Ip>
+struct __deduce_iterator_category<_Ip> {
+ using type = forward_iterator_tag;
+};
+
+template<class _Ip>
+struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {};
+
+// [iterator.traits]/3.2.3
+// If the qualified-id `I::iterator-category` is valid and denotes a type, `iterator-category` names
+// that type.
+template<__has_member_iterator_category _Ip>
+struct __iterator_traits_iterator_category<_Ip> {
+ using type = typename _Ip::iterator_category;
+};
+
+// otherwise, it names void.
+template<class>
+struct __iterator_traits_difference_type { using type = void; };
+
+// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then
+// `difference_type` names that type;
+template<class _Ip>
+requires requires { typename incrementable_traits<_Ip>::difference_type; }
+struct __iterator_traits_difference_type<_Ip> {
+ using type = typename incrementable_traits<_Ip>::difference_type;
+};
+
+// [iterator.traits]/3.4
+// Otherwise, `iterator_traits<I>` has no members by any of the above names.
+template<class>
+struct __iterator_traits {};
+
+// [iterator.traits]/3.1
+// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and
+// `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members:
+template<__specifies_members _Ip>
+struct __iterator_traits<_Ip> {
+ using iterator_category = typename _Ip::iterator_category;
+ using value_type = typename _Ip::value_type;
+ using difference_type = typename _Ip::difference_type;
+ using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type;
+ using reference = typename _Ip::reference;
+};
+
+// [iterator.traits]/3.2
+// Otherwise, if `I` satisfies the exposition-only concept `cpp17-input-iterator`,
+// `iterator-traits<I>` has the following publicly accessible members:
+template<__cpp17_input_iterator_missing_members _Ip>
+struct __iterator_traits<_Ip> {
+ using iterator_category = typename __iterator_traits_iterator_category<_Ip>::type;
+ using value_type = typename indirectly_readable_traits<_Ip>::value_type;
+ using difference_type = typename incrementable_traits<_Ip>::difference_type;
+ using pointer = typename __iterator_traits_member_pointer_or_arrow_or_void<_Ip>::type;
+ using reference = typename __iterator_traits_member_reference<_Ip>::type;
+};
+
+// Otherwise, if `I` satisfies the exposition-only concept `cpp17-iterator`, then
+// `iterator_traits<I>` has the following publicly accessible members:
+template<__cpp17_iterator_missing_members _Ip>
+struct __iterator_traits<_Ip> {
+ using iterator_category = output_iterator_tag;
+ using value_type = void;
+ using difference_type = typename __iterator_traits_difference_type<_Ip>::type;
+ using pointer = void;
+ using reference = void;
+};
+
+template<class _Ip>
+struct iterator_traits : __iterator_traits<_Ip> {
+ using __primary_template = iterator_traits;
+};
+
+#else // !defined(_LIBCPP_HAS_NO_RANGES)
+
+template <class _Iter, bool> struct __iterator_traits {};
+
+template <class _Iter, bool> struct __iterator_traits_impl {};
+
+template <class _Iter>
+struct __iterator_traits_impl<_Iter, true>
+{
+ typedef typename _Iter::difference_type difference_type;
+ typedef typename _Iter::value_type value_type;
+ typedef typename _Iter::pointer pointer;
+ typedef typename _Iter::reference reference;
+ typedef typename _Iter::iterator_category iterator_category;
+};
+
+template <class _Iter>
+struct __iterator_traits<_Iter, true>
+ : __iterator_traits_impl
+ <
+ _Iter,
+ is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
+ is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value
+ >
+{};
+
+// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
+// exists. Else iterator_traits<Iterator> will be an empty class. This is a
+// conforming extension which allows some programs to compile and behave as
+// the client expects instead of failing at compile time.
+
+template <class _Iter>
+struct _LIBCPP_TEMPLATE_VIS iterator_traits
+ : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {
+
+ using __primary_template = iterator_traits;
+};
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+template<class _Tp>
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+requires is_object_v<_Tp>
+#endif
+struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
+{
+ typedef ptrdiff_t difference_type;
+ typedef typename remove_cv<_Tp>::type value_type;
+ typedef _Tp* pointer;
+ typedef _Tp& reference;
+ typedef random_access_iterator_tag iterator_category;
+#if _LIBCPP_STD_VER > 17
+ typedef contiguous_iterator_tag iterator_concept;
+#endif
+};
+
+template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
+struct __has_iterator_category_convertible_to
+ : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>
+{};
+
+template <class _Tp, class _Up>
+struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {};
+
+template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value>
+struct __has_iterator_concept_convertible_to
+ : is_convertible<typename _Tp::iterator_concept, _Up>
+{};
+
+template <class _Tp, class _Up>
+struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {};
+
+template <class _Tp>
+struct __is_cpp17_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
+
+template <class _Tp>
+struct __is_cpp17_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
+
+template <class _Tp>
+struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
+
+template <class _Tp>
+struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
+
+// __is_cpp17_contiguous_iterator determines if an iterator is known by
+// libc++ to be contiguous, either because it advertises itself as such
+// (in C++20) or because it is a pointer type or a known trivial wrapper
+// around a (possibly fancy) pointer type, such as __wrap_iter<T*>.
+// Such iterators receive special "contiguous" optimizations in
+// std::copy and std::sort.
+//
+#if _LIBCPP_STD_VER > 17
+template <class _Tp>
+struct __is_cpp17_contiguous_iterator : _Or<
+ __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag>,
+ __has_iterator_concept_convertible_to<_Tp, contiguous_iterator_tag>
+> {};
+#else
+template <class _Tp>
+struct __is_cpp17_contiguous_iterator : false_type {};
+#endif
+
+// Any native pointer which is an iterator is also a contiguous iterator.
+template <class _Up>
+struct __is_cpp17_contiguous_iterator<_Up*> : true_type {};
+
+
+template <class _Tp>
+struct __is_exactly_cpp17_input_iterator
+ : public integral_constant<bool,
+ __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
+ !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _InputIterator>
+using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
+
+template<class _InputIterator>
+using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
+
+template<class _InputIterator>
+using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;
+
+template<class _InputIterator>
+using __iter_to_alloc_type = pair<
+ add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>,
+ typename iterator_traits<_InputIterator>::value_type::second_type>;
+#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/move_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/move_iterator.h
new file mode 100644
index 000000000000..7819743bdb39
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/move_iterator.h
@@ -0,0 +1,189 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_MOVE_ITERATOR_H
+#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Iter>
+class _LIBCPP_TEMPLATE_VIS move_iterator
+{
+private:
+ _Iter __i;
+public:
+ typedef _Iter iterator_type;
+ typedef typename iterator_traits<iterator_type>::value_type value_type;
+ typedef typename iterator_traits<iterator_type>::difference_type difference_type;
+ typedef iterator_type pointer;
+ typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
+ random_access_iterator_tag,
+ typename iterator_traits<_Iter>::iterator_category> iterator_category;
+#if _LIBCPP_STD_VER > 17
+ typedef input_iterator_tag iterator_concept;
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+ typedef typename iterator_traits<iterator_type>::reference __reference;
+ typedef typename conditional<
+ is_reference<__reference>::value,
+ typename remove_reference<__reference>::type&&,
+ __reference
+ >::type reference;
+#else
+ typedef typename iterator_traits<iterator_type>::reference reference;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator() : __i() {}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ explicit move_iterator(_Iter __x) : __i(__x) {}
+
+ template <class _Up, class = _EnableIf<
+ !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}
+
+ template <class _Up, class = _EnableIf<
+ !is_same<_Up, _Iter>::value &&
+ is_convertible<_Up const&, _Iter>::value &&
+ is_assignable<_Iter&, _Up const&>::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator=(const move_iterator<_Up>& __u) {
+ __i = __u.base();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator*() const { return static_cast<reference>(*__i); }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ pointer operator->() const { return __i;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator++() {++__i; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator--() {--__i; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator+=(difference_type __n) {__i += __n; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); }
+};
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() != __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() > __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() >= __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() <= __y.base();
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto
+operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+-> decltype(__x.base() - __y.base())
+{
+ return __x.base() - __y.base();
+}
+#else
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename move_iterator<_Iter1>::difference_type
+operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+ return __x.base() - __y.base();
+}
+#endif
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+move_iterator<_Iter>
+operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
+{
+ return move_iterator<_Iter>(__x.base() + __n);
+}
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+move_iterator<_Iter>
+make_move_iterator(_Iter __i)
+{
+ return move_iterator<_Iter>(__i);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/next.h b/contrib/llvm-project/libcxx/include/__iterator/next.h
new file mode 100644
index 000000000000..1eecaa9750ba
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/next.h
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_NEXT_H
+#define _LIBCPP___ITERATOR_NEXT_H
+
+#include <__config>
+#include <__debug>
+#include <__function_like.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type
+ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
+ _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
+ "Attempt to next(it, n) with negative n on a non-bidirectional iterator");
+
+ _VSTD::advance(__x, __n);
+ return __x;
+}
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+struct __next_fn final : private __function_like {
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __next_fn(__tag __x) noexcept : __function_like(__x) {}
+
+ template <input_or_output_iterator _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x) const {
+ ++__x;
+ return __x;
+ }
+
+ template <input_or_output_iterator _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
+ ranges::advance(__x, __n);
+ return __x;
+ }
+
+ template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x, _Sp __bound) const {
+ ranges::advance(__x, __bound);
+ return __x;
+ }
+
+ template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound) const {
+ ranges::advance(__x, __n, __bound);
+ return __x;
+ }
+};
+
+inline constexpr auto next = __next_fn(__function_like::__tag());
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_PRIMITIVES_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/ostream_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/ostream_iterator.h
new file mode 100644
index 000000000000..5b4466c86399
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/ostream_iterator.h
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
+#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <iosfwd> // for forward declarations of char_traits and basic_ostream
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
+class _LIBCPP_TEMPLATE_VIS ostream_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<output_iterator_tag, void, void, void, void>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef basic_ostream<_CharT, _Traits> ostream_type;
+
+private:
+ ostream_type* __out_stream_;
+ const char_type* __delim_;
+public:
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
+ : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
+ : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
+ {
+ *__out_stream_ << __value_;
+ if (__delim_)
+ *__out_stream_ << __delim_;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/ostreambuf_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/ostreambuf_iterator.h
new file mode 100644
index 000000000000..90309dacd429
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/ostreambuf_iterator.h
@@ -0,0 +1,81 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
+#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <iosfwd> // for forward declaration of basic_streambuf
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _CharT, class _Traits>
+class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<output_iterator_tag, void, void, void, void>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef basic_streambuf<_CharT, _Traits> streambuf_type;
+ typedef basic_ostream<_CharT, _Traits> ostream_type;
+
+private:
+ streambuf_type* __sbuf_;
+public:
+ _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT
+ : __sbuf_(__s.rdbuf()) {}
+ _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT
+ : __sbuf_(__s) {}
+ _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
+ {
+ if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
+ __sbuf_ = nullptr;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
+ _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;}
+
+ template <class _Ch, class _Tr>
+ friend
+ _LIBCPP_HIDDEN
+ ostreambuf_iterator<_Ch, _Tr>
+ __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
+ const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
+ ios_base& __iob, _Ch __fl);
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/prev.h b/contrib/llvm-project/libcxx/include/__iterator/prev.h
new file mode 100644
index 000000000000..cb8a57135504
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/prev.h
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_PREV_H
+#define _LIBCPP___ITERATOR_PREV_H
+
+#include <__config>
+#include <__debug>
+#include <__function_like.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type
+ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
+ _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
+ "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator");
+ _VSTD::advance(__x, -__n);
+ return __x;
+}
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+struct __prev_fn final : private __function_like {
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __prev_fn(__tag __x) noexcept : __function_like(__x) {}
+
+ template <bidirectional_iterator _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x) const {
+ --__x;
+ return __x;
+ }
+
+ template <bidirectional_iterator _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
+ ranges::advance(__x, -__n);
+ return __x;
+ }
+
+ template <bidirectional_iterator _Ip>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound) const {
+ ranges::advance(__x, -__n, __bound);
+ return __x;
+ }
+};
+
+inline constexpr auto prev = __prev_fn(__function_like::__tag());
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_PREV_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/projected.h b/contrib/llvm-project/libcxx/include/__iterator/projected.h
new file mode 100644
index 000000000000..7064a5eb9198
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/projected.h
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___ITERATOR_PROJECTED_H
+#define _LIBCPP___ITERATOR_PROJECTED_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
+struct projected {
+ using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
+ indirect_result_t<_Proj&, _It> operator*() const; // not defined
+};
+
+template<weakly_incrementable _It, class _Proj>
+struct incrementable_traits<projected<_It, _Proj>> {
+ using difference_type = iter_difference_t<_It>;
+};
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_PROJECTED_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h b/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h
new file mode 100644
index 000000000000..fbad106e4ee1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/readable_traits.h
@@ -0,0 +1,91 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H
+#define _LIBCPP___ITERATOR_READABLE_TRAITS_H
+
+#include <__config>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// [readable.traits]
+template<class> struct __cond_value_type {};
+
+template<class _Tp>
+requires is_object_v<_Tp>
+struct __cond_value_type<_Tp> { using value_type = remove_cv_t<_Tp>; };
+
+template<class _Tp>
+concept __has_member_value_type = requires { typename _Tp::value_type; };
+
+template<class _Tp>
+concept __has_member_element_type = requires { typename _Tp::element_type; };
+
+template<class> struct indirectly_readable_traits {};
+
+template<class _Ip>
+requires is_array_v<_Ip>
+struct indirectly_readable_traits<_Ip> {
+ using value_type = remove_cv_t<remove_extent_t<_Ip>>;
+};
+
+template<class _Ip>
+struct indirectly_readable_traits<const _Ip> : indirectly_readable_traits<_Ip> {};
+
+template<class _Tp>
+struct indirectly_readable_traits<_Tp*> : __cond_value_type<_Tp> {};
+
+template<__has_member_value_type _Tp>
+struct indirectly_readable_traits<_Tp>
+ : __cond_value_type<typename _Tp::value_type> {};
+
+template<__has_member_element_type _Tp>
+struct indirectly_readable_traits<_Tp>
+ : __cond_value_type<typename _Tp::element_type> {};
+
+// Pre-emptively applies LWG3541
+template<__has_member_value_type _Tp>
+requires __has_member_element_type<_Tp>
+struct indirectly_readable_traits<_Tp> {};
+template<__has_member_value_type _Tp>
+requires __has_member_element_type<_Tp> &&
+ same_as<remove_cv_t<typename _Tp::element_type>,
+ remove_cv_t<typename _Tp::value_type>>
+struct indirectly_readable_traits<_Tp>
+ : __cond_value_type<typename _Tp::value_type> {};
+
+template <class>
+struct iterator_traits;
+
+// Let `RI` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes
+// `indirectly_readable_traits<RI>::value_type` if `iterator_traits<RI>` names a specialization
+// generated from the primary template, and `iterator_traits<RI>::value_type` otherwise.
+template <class _Ip>
+using iter_value_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
+ indirectly_readable_traits<remove_cvref_t<_Ip> >,
+ iterator_traits<remove_cvref_t<_Ip> > >::value_type;
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/reverse_access.h b/contrib/llvm-project/libcxx/include/__iterator/reverse_access.h
new file mode 100644
index 000000000000..66cc3568c1c1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/reverse_access.h
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_REVERSE_ACCESS_H
+#define _LIBCPP___ITERATOR_REVERSE_ACCESS_H
+
+#include <__config>
+#include <__iterator/reverse_iterator.h>
+#include <cstddef>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+#if _LIBCPP_STD_VER > 11
+
+template <class _Tp, size_t _Np>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
+{
+ return reverse_iterator<_Tp*>(__array + _Np);
+}
+
+template <class _Tp, size_t _Np>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
+{
+ return reverse_iterator<_Tp*>(__array);
+}
+
+template <class _Ep>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
+{
+ return reverse_iterator<const _Ep*>(__il.end());
+}
+
+template <class _Ep>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
+{
+ return reverse_iterator<const _Ep*>(__il.begin());
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
+{
+ return __c.rbegin();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
+{
+ return __c.rbegin();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto rend(_Cp& __c) -> decltype(__c.rend())
+{
+ return __c.rend();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto rend(const _Cp& __c) -> decltype(__c.rend())
+{
+ return __c.rend();
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
+{
+ return _VSTD::rbegin(__c);
+}
+
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
+{
+ return _VSTD::rend(__c);
+}
+
+#endif
+
+#endif // !defined(_LIBCPP_CXX03_LANG)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h b/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h
new file mode 100644
index 000000000000..76424a89a19c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/reverse_iterator.h
@@ -0,0 +1,239 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
+#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
+
+#include <__config>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class = void>
+struct __is_stashing_iterator : false_type {};
+
+template <class _Tp>
+struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type>
+ : true_type {};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Iter>
+class _LIBCPP_TEMPLATE_VIS reverse_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<typename iterator_traits<_Iter>::iterator_category,
+ typename iterator_traits<_Iter>::value_type,
+ typename iterator_traits<_Iter>::difference_type,
+ typename iterator_traits<_Iter>::pointer,
+ typename iterator_traits<_Iter>::reference>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+private:
+#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
+ _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
+#endif
+
+ static_assert(!__is_stashing_iterator<_Iter>::value,
+ "The specified iterator type cannot be used with reverse_iterator; "
+ "Using stashing iterators with reverse_iterator causes undefined behavior");
+
+protected:
+ _Iter current;
+public:
+ typedef _Iter iterator_type;
+ typedef typename iterator_traits<_Iter>::difference_type difference_type;
+ typedef typename iterator_traits<_Iter>::reference reference;
+ typedef typename iterator_traits<_Iter>::pointer pointer;
+ typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
+ random_access_iterator_tag,
+ typename iterator_traits<_Iter>::iterator_category> iterator_category;
+ typedef typename iterator_traits<_Iter>::value_type value_type;
+
+#if _LIBCPP_STD_VER > 17
+ typedef _If<__is_cpp17_random_access_iterator<_Iter>::value,
+ random_access_iterator_tag,
+ bidirectional_iterator_tag> iterator_concept;
+#endif
+
+#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator() : __t(), current() {}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
+
+ template <class _Up, class = _EnableIf<
+ !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator(const reverse_iterator<_Up>& __u)
+ : __t(__u.base()), current(__u.base())
+ { }
+
+ template <class _Up, class = _EnableIf<
+ !is_same<_Up, _Iter>::value &&
+ is_convertible<_Up const&, _Iter>::value &&
+ is_assignable<_Up const&, _Iter>::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
+ __t = current = __u.base();
+ return *this;
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator() : current() {}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ explicit reverse_iterator(_Iter __x) : current(__x) {}
+
+ template <class _Up, class = _EnableIf<
+ !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator(const reverse_iterator<_Up>& __u)
+ : current(__u.base())
+ { }
+
+ template <class _Up, class = _EnableIf<
+ !is_same<_Up, _Iter>::value &&
+ is_convertible<_Up const&, _Iter>::value &&
+ is_assignable<_Up const&, _Iter>::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
+ current = __u.base();
+ return *this;
+ }
+#endif
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _Iter base() const {return current;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator*() const {_Iter __tmp = current; return *--__tmp;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ pointer operator->() const {return _VSTD::addressof(operator*());}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator& operator++() {--current; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator& operator--() {++current; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ reference operator[](difference_type __n) const {return *(*this + __n);}
+};
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __x.base() > __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __x.base() != __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __x.base() <= __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+bool
+operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __x.base() >= __y.base();
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+auto
+operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+-> decltype(__y.base() - __x.base())
+{
+ return __y.base() - __x.base();
+}
+#else
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename reverse_iterator<_Iter1>::difference_type
+operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+ return __y.base() - __x.base();
+}
+#endif
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+reverse_iterator<_Iter>
+operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
+{
+ return reverse_iterator<_Iter>(__x.base() - __n);
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
+{
+ return reverse_iterator<_Iter>(__i);
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/size.h b/contrib/llvm-project/libcxx/include/__iterator/size.h
new file mode 100644
index 000000000000..259424f1d314
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/size.h
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_SIZE_H
+#define _LIBCPP___ITERATOR_SIZE_H
+
+#include <__config>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Cont>
+_LIBCPP_INLINE_VISIBILITY
+constexpr auto size(const _Cont& __c)
+_NOEXCEPT_(noexcept(__c.size()))
+-> decltype (__c.size())
+{ return __c.size(); }
+
+template <class _Tp, size_t _Sz>
+_LIBCPP_INLINE_VISIBILITY
+constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
+
+#if _LIBCPP_STD_VER > 17
+template <class _Cont>
+_LIBCPP_INLINE_VISIBILITY
+constexpr auto ssize(const _Cont& __c)
+_NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size())))
+-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>
+{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); }
+
+template <class _Tp, ptrdiff_t _Sz>
+_LIBCPP_INLINE_VISIBILITY
+constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; }
+#endif
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_SIZE_H
diff --git a/contrib/llvm-project/libcxx/include/__iterator/wrap_iter.h b/contrib/llvm-project/libcxx/include/__iterator/wrap_iter.h
new file mode 100644
index 000000000000..e35a372b4267
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__iterator/wrap_iter.h
@@ -0,0 +1,300 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ITERATOR_WRAP_ITER_H
+#define _LIBCPP___ITERATOR_WRAP_ITER_H
+
+#include <__config>
+#include <__debug>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h> // __to_address
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Iter>
+class __wrap_iter
+{
+public:
+ typedef _Iter iterator_type;
+ typedef typename iterator_traits<iterator_type>::value_type value_type;
+ typedef typename iterator_traits<iterator_type>::difference_type difference_type;
+ typedef typename iterator_traits<iterator_type>::pointer pointer;
+ typedef typename iterator_traits<iterator_type>::reference reference;
+ typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
+#if _LIBCPP_STD_VER > 17
+ typedef contiguous_iterator_tag iterator_concept;
+#endif
+
+private:
+ iterator_type __i;
+public:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+ : __i{}
+#endif
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__insert_i(this);
+#endif
+ }
+ template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+ __wrap_iter(const __wrap_iter<_Up>& __u,
+ typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
+ : __i(__u.base())
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ __get_db()->__iterator_copy(this, &__u);
+#endif
+ }
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+ __wrap_iter(const __wrap_iter& __x)
+ : __i(__x.base())
+ {
+ __get_db()->__iterator_copy(this, &__x);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+ __wrap_iter& operator=(const __wrap_iter& __x)
+ {
+ if (this != &__x)
+ {
+ __get_db()->__iterator_copy(this, &__x);
+ __i = __x.__i;
+ }
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+ ~__wrap_iter()
+ {
+ __get_db()->__erase_i(this);
+ }
+#endif
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable iterator");
+#endif
+ return *__i;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to dereference a non-dereferenceable iterator");
+#endif
+ return _VSTD::__to_address(__i);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+ "Attempted to increment a non-incrementable iterator");
+#endif
+ ++__i;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT
+ {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
+ "Attempted to decrement a non-decrementable iterator");
+#endif
+ --__i;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT
+ {__wrap_iter __tmp(*this); --(*this); return __tmp;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
+ {__wrap_iter __w(*this); __w += __n; return __w;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
+ "Attempted to add/subtract an iterator outside its valid range");
+#endif
+ __i += __n;
+ return *this;
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT
+ {return *this + (-__n);}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
+ {*this += -__n; return *this;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT
+ {
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
+ "Attempted to subscript an iterator outside its valid range");
+#endif
+ return __i[__n];
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
+ {
+ __get_db()->__insert_ic(this, __p);
+ }
+#else
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
+#endif
+
+ template <class _Up> friend class __wrap_iter;
+ template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
+ template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
+ template <class _Tp, size_t> friend class _LIBCPP_TEMPLATE_VIS span;
+};
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return __x.base() == __y.base();
+}
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
+ "Attempted to compare incomparable iterators");
+#endif
+ return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
+ "Attempted to compare incomparable iterators");
+#endif
+ return __x.base() < __y.base();
+}
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return !(__x == __y);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return !(__x == __y);
+}
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return __y < __x;
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return __y < __x;
+}
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return !(__x < __y);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return !(__x < __y);
+}
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+ return !(__y < __x);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+ return !(__y < __x);
+}
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+#ifndef _LIBCPP_CXX03_LANG
+auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+ -> decltype(__x.base() - __y.base())
+#else
+typename __wrap_iter<_Iter1>::difference_type
+operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+#endif // C++03
+{
+#if _LIBCPP_DEBUG_LEVEL == 2
+ _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
+ "Attempted to subtract incompatible iterators");
+#endif
+ return __x.base() - __y.base();
+}
+
+template <class _Iter1>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT
+{
+ __x += __n;
+ return __x;
+}
+
+#if _LIBCPP_STD_VER <= 17
+template <class _It>
+struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {};
+#endif
+
+template <class _Iter>
+_LIBCPP_CONSTEXPR
+decltype(_VSTD::__to_address(declval<_Iter>()))
+__to_address(__wrap_iter<_Iter> __w) _NOEXCEPT {
+ return _VSTD::__to_address(__w.base());
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___ITERATOR_WRAP_ITER_H
diff --git a/contrib/llvm-project/libcxx/include/__libcpp_version b/contrib/llvm-project/libcxx/include/__libcpp_version
index e334181b4006..09514aa4db92 100644
--- a/contrib/llvm-project/libcxx/include/__libcpp_version
+++ b/contrib/llvm-project/libcxx/include/__libcpp_version
@@ -1 +1 @@
-12000
+13000
diff --git a/contrib/llvm-project/libcxx/include/__locale b/contrib/llvm-project/libcxx/include/__locale
index 77e5faab2676..ad742997d9ac 100644
--- a/contrib/llvm-project/libcxx/include/__locale
+++ b/contrib/llvm-project/libcxx/include/__locale
@@ -10,8 +10,8 @@
#ifndef _LIBCPP___LOCALE
#define _LIBCPP___LOCALE
-#include <__config>
#include <__availability>
+#include <__config>
#include <string>
#include <memory>
#include <utility>
@@ -1161,7 +1161,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
@@ -1337,7 +1337,7 @@ protected:
virtual int do_max_length() const _NOEXCEPT;
};
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
@@ -1455,7 +1455,7 @@ _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VI
_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) // deprecated in C++20
_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) // deprecated in C++20
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>) // C++20
_LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>) // C++20
#endif
@@ -1484,14 +1484,14 @@ struct __narrow_to_utf8<8>
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
-struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<16>
+struct _LIBCPP_TYPE_VIS __narrow_to_utf8<16>
: public codecvt<char16_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
+ ~__narrow_to_utf8();
template <class _OutputIterator, class _CharT>
_LIBCPP_INLINE_VISIBILITY
@@ -1520,14 +1520,14 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
-struct _LIBCPP_TEMPLATE_VIS __narrow_to_utf8<32>
+struct _LIBCPP_TYPE_VIS __narrow_to_utf8<32>
: public codecvt<char32_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- _LIBCPP_EXPORTED_FROM_ABI ~__narrow_to_utf8();
+ ~__narrow_to_utf8();
template <class _OutputIterator, class _CharT>
_LIBCPP_INLINE_VISIBILITY
@@ -1578,14 +1578,14 @@ struct __widen_from_utf8<8>
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
-struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<16>
+struct _LIBCPP_TYPE_VIS __widen_from_utf8<16>
: public codecvt<char16_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
+ ~__widen_from_utf8();
template <class _OutputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -1614,14 +1614,14 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
template <>
-struct _LIBCPP_TEMPLATE_VIS __widen_from_utf8<32>
+struct _LIBCPP_TYPE_VIS __widen_from_utf8<32>
: public codecvt<char32_t, char, mbstate_t>
{
_LIBCPP_INLINE_VISIBILITY
__widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
_LIBCPP_SUPPRESS_DEPRECATED_POP
- _LIBCPP_EXPORTED_FROM_ABI ~__widen_from_utf8();
+ ~__widen_from_utf8();
template <class _OutputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -1756,4 +1756,4 @@ private:
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP___LOCALE
+#endif // _LIBCPP___LOCALE
diff --git a/contrib/llvm-project/libcxx/include/__memory/base.h b/contrib/llvm-project/libcxx/include/__memory/addressof.h
index 70728bd7f8ef..5efdb5878625 100644
--- a/contrib/llvm-project/libcxx/include/__memory/base.h
+++ b/contrib/llvm-project/libcxx/include/__memory/addressof.h
@@ -7,12 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___MEMORY_BASE_H
-#define _LIBCPP___MEMORY_BASE_H
+#ifndef _LIBCPP___MEMORY_ADDRESSOF_H
+#define _LIBCPP___MEMORY_ADDRESSOF_H
#include <__config>
-#include <__debug>
-#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -23,7 +21,6 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-// addressof
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
template <class _Tp>
@@ -92,36 +89,8 @@ addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
#endif
-// construct_at
-
-#if _LIBCPP_STD_VER > 17
-
-template<class _Tp, class ..._Args, class = decltype(
- ::new (_VSTD::declval<void*>()) _Tp(_VSTD::declval<_Args>()...)
-)>
-_LIBCPP_INLINE_VISIBILITY
-constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
- _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
- return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
-}
-
-#endif
-
-// destroy_at
-
-#if _LIBCPP_STD_VER > 14
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void destroy_at(_Tp* __loc) {
- _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
- __loc->~_Tp();
-}
-
-#endif
-
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___MEMORY_BASE_H
+#endif // _LIBCPP___MEMORY_ADDRESSOF_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/utilities.h b/contrib/llvm-project/libcxx/include/__memory/allocation_guard.h
index aac3d11cab57..4987af293d14 100644
--- a/contrib/llvm-project/libcxx/include/__memory/utilities.h
+++ b/contrib/llvm-project/libcxx/include/__memory/allocation_guard.h
@@ -7,12 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___MEMORY_UTILITIES_H
-#define _LIBCPP___MEMORY_UTILITIES_H
+#ifndef _LIBCPP___MEMORY_ALLOCATION_GUARD_H
+#define _LIBCPP___MEMORY_ALLOCATION_GUARD_H
#include <__config>
#include <__memory/allocator_traits.h>
#include <cstddef>
+#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -85,4 +86,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___MEMORY_UTILITIES_H
+#endif // _LIBCPP___MEMORY_ALLOCATION_GUARD_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/allocator.h b/contrib/llvm-project/libcxx/include/__memory/allocator.h
new file mode 100644
index 000000000000..2c21a16e7e84
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/allocator.h
@@ -0,0 +1,254 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_ALLOCATOR_H
+#define _LIBCPP___MEMORY_ALLOCATOR_H
+
+#include <__config>
+#include <__memory/allocator_traits.h>
+#include <__utility/forward.h>
+#include <cstddef>
+#include <new>
+#include <stdexcept>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> class allocator;
+
+#if _LIBCPP_STD_VER <= 17
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<void>
+{
+public:
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type;
+
+ template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
+};
+
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<const void>
+{
+public:
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;
+
+ template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
+};
+#endif
+
+// This class provides a non-trivial default constructor to the class that derives from it
+// if the condition is satisfied.
+//
+// The second template parameter exists to allow giving a unique type to __non_trivial_if,
+// which makes it possible to avoid breaking the ABI when making this a base class of an
+// existing class. Without that, imagine we have classes D1 and D2, both of which used to
+// have no base classes, but which now derive from __non_trivial_if. The layout of a class
+// that inherits from both D1 and D2 will change because the two __non_trivial_if base
+// classes are not allowed to share the same address.
+//
+// By making those __non_trivial_if base classes unique, we work around this problem and
+// it is safe to start deriving from __non_trivial_if in existing classes.
+template <bool _Cond, class _Unique>
+struct __non_trivial_if { };
+
+template <class _Unique>
+struct __non_trivial_if<true, _Unique> {
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR __non_trivial_if() _NOEXCEPT { }
+};
+
+// allocator
+//
+// Note: For ABI compatibility between C++20 and previous standards, we make
+// allocator<void> trivial in C++20.
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS allocator
+ : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> >
+{
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef _Tp value_type;
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ allocator() _NOEXCEPT _LIBCPP_DEFAULT
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ allocator(const allocator<_Up>&) _NOEXCEPT { }
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ _Tp* allocate(size_t __n) {
+ if (__n > allocator_traits<allocator>::max_size(*this))
+ __throw_length_error("allocator<T>::allocate(size_t n)"
+ " 'n' exceeds maximum supported size");
+ if (__libcpp_is_constant_evaluated()) {
+ return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
+ } else {
+ return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
+ if (__libcpp_is_constant_evaluated()) {
+ ::operator delete(__p);
+ } else {
+ _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+ }
+
+ // C++20 Removed members
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
+
+ template <class _Up>
+ struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
+ typedef allocator<_Up> other;
+ };
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ pointer address(reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
+ }
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ const_pointer address(const_reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
+ }
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
+ _Tp* allocate(size_t __n, const void*) {
+ return allocate(__n);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
+ return size_type(~0) / sizeof(_Tp);
+ }
+
+ template <class _Up, class... _Args>
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void construct(_Up* __p, _Args&&... __args) {
+ ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void destroy(pointer __p) {
+ __p->~_Tp();
+ }
+#endif
+};
+
+template <class _Tp>
+class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
+ : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> >
+{
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef const _Tp value_type;
+ typedef true_type propagate_on_container_move_assignment;
+ typedef true_type is_always_equal;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ allocator() _NOEXCEPT _LIBCPP_DEFAULT
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ allocator(const allocator<_Up>&) _NOEXCEPT { }
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ const _Tp* allocate(size_t __n) {
+ if (__n > allocator_traits<allocator>::max_size(*this))
+ __throw_length_error("allocator<const T>::allocate(size_t n)"
+ " 'n' exceeds maximum supported size");
+ if (__libcpp_is_constant_evaluated()) {
+ return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
+ } else {
+ return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void deallocate(const _Tp* __p, size_t __n) {
+ if (__libcpp_is_constant_evaluated()) {
+ ::operator delete(const_cast<_Tp*>(__p));
+ } else {
+ _VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+ }
+
+ // C++20 Removed members
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
+
+ template <class _Up>
+ struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
+ typedef allocator<_Up> other;
+ };
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ const_pointer address(const_reference __x) const _NOEXCEPT {
+ return _VSTD::addressof(__x);
+ }
+
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
+ const _Tp* allocate(size_t __n, const void*) {
+ return allocate(__n);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
+ return size_type(~0) / sizeof(_Tp);
+ }
+
+ template <class _Up, class... _Args>
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void construct(_Up* __p, _Args&&... __args) {
+ ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+ }
+
+ _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
+ void destroy(pointer __p) {
+ __p->~_Tp();
+ }
+#endif
+};
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_ALLOCATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/allocator_arg_t.h b/contrib/llvm-project/libcxx/include/__memory/allocator_arg_t.h
new file mode 100644
index 000000000000..830c6b8148eb
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/allocator_arg_t.h
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H
+#define _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H
+
+#include <__config>
+#include <__memory/uses_allocator.h>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; };
+
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
+extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
+#else
+/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
+#endif
+
+#ifndef _LIBCPP_CXX03_LANG
+
+// allocator construction
+
+template <class _Tp, class _Alloc, class ..._Args>
+struct __uses_alloc_ctor_imp
+{
+ typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc;
+ static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
+ static const bool __ic =
+ is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
+ static const int value = __ua ? 2 - __ic : 0;
+};
+
+template <class _Tp, class _Alloc, class ..._Args>
+struct __uses_alloc_ctor
+ : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
+ {};
+
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
+{
+ new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
+}
+
+// FIXME: This should have a version which takes a non-const alloc.
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+ new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
+}
+
+// FIXME: This should have a version which takes a non-const alloc.
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+ new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/allocator_traits.h b/contrib/llvm-project/libcxx/include/__memory/allocator_traits.h
index 9443f61b71bc..a02af0deafc9 100644
--- a/contrib/llvm-project/libcxx/include/__memory/allocator_traits.h
+++ b/contrib/llvm-project/libcxx/include/__memory/allocator_traits.h
@@ -11,8 +11,10 @@
#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
#include <__config>
-#include <__memory/base.h>
+#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
+#include <__utility/forward.h>
+#include <limits>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -253,7 +255,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
struct rebind_traits {
using other = allocator_traits<typename rebind_alloc<_Tp>::other>;
};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
static pointer allocate(allocator_type& __a, size_type __n) {
@@ -360,8 +362,10 @@ struct __rebind_alloc_helper {
template <class _Tp>
struct __is_default_allocator : false_type { };
+template <class> class allocator;
+
template <class _Tp>
-struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type { };
+struct __is_default_allocator<allocator<_Tp> > : true_type { };
// __is_cpp17_move_insertable
template <class _Alloc, class = void>
@@ -398,4 +402,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
+#endif // _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/auto_ptr.h b/contrib/llvm-project/libcxx/include/__memory/auto_ptr.h
new file mode 100644
index 000000000000..f8d2b507b4c6
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/auto_ptr.h
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_AUTO_PTR_H
+#define _LIBCPP___MEMORY_AUTO_PTR_H
+
+#include <__config>
+#include <__nullptr>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref
+{
+ _Tp* __ptr_;
+};
+
+template<class _Tp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr
+{
+private:
+ _Tp* __ptr_;
+public:
+ typedef _Tp element_type;
+
+ _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) _NOEXCEPT : __ptr_(__p) {}
+ _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) _NOEXCEPT : __ptr_(__p.release()) {}
+ template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) _NOEXCEPT
+ : __ptr_(__p.release()) {}
+ _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) _NOEXCEPT
+ {reset(__p.release()); return *this;}
+ template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) _NOEXCEPT
+ {reset(__p.release()); return *this;}
+ _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) _NOEXCEPT
+ {reset(__p.__ptr_); return *this;}
+ _LIBCPP_INLINE_VISIBILITY ~auto_ptr() _NOEXCEPT {delete __ptr_;}
+
+ _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const _NOEXCEPT
+ {return *__ptr_;}
+ _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const _NOEXCEPT {return __ptr_;}
+ _LIBCPP_INLINE_VISIBILITY _Tp* get() const _NOEXCEPT {return __ptr_;}
+ _LIBCPP_INLINE_VISIBILITY _Tp* release() _NOEXCEPT
+ {
+ _Tp* __t = __ptr_;
+ __ptr_ = nullptr;
+ return __t;
+ }
+ _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) _NOEXCEPT
+ {
+ if (__ptr_ != __p)
+ delete __ptr_;
+ __ptr_ = __p;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
+ template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() _NOEXCEPT
+ {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;}
+ template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() _NOEXCEPT
+ {return auto_ptr<_Up>(release());}
+};
+
+template <>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void>
+{
+public:
+ typedef void element_type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_AUTO_PTR_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/compressed_pair.h b/contrib/llvm-project/libcxx/include/__memory/compressed_pair.h
new file mode 100644
index 000000000000..08f0318a10f4
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/compressed_pair.h
@@ -0,0 +1,201 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_COMPRESSED_PAIR_H
+#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <tuple> // needed in c++03 for some constructors
+#include <type_traits>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Tag used to default initialize one or both of the pair's elements.
+struct __default_init_tag {};
+struct __value_init_tag {};
+
+template <class _Tp, int _Idx,
+ bool _CanBeEmptyBase =
+ is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
+struct __compressed_pair_elem {
+ typedef _Tp _ParamT;
+ typedef _Tp& reference;
+ typedef const _Tp& const_reference;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__value_init_tag) : __value_() {}
+
+ template <class _Up, class = typename enable_if<
+ !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR explicit
+ __compressed_pair_elem(_Up&& __u)
+ : __value_(_VSTD::forward<_Up>(__u))
+ {
+ }
+
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args, size_t... _Indexes>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
+ __tuple_indices<_Indexes...>)
+ : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
+#endif
+
+
+ _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference __get() const _NOEXCEPT { return __value_; }
+
+private:
+ _Tp __value_;
+};
+
+template <class _Tp, int _Idx>
+struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
+ typedef _Tp _ParamT;
+ typedef _Tp& reference;
+ typedef const _Tp& const_reference;
+ typedef _Tp __value_type;
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__default_init_tag) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair_elem(__value_init_tag) : __value_type() {}
+
+ template <class _Up, class = typename enable_if<
+ !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
+ >::type>
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR explicit
+ __compressed_pair_elem(_Up&& __u)
+ : __value_type(_VSTD::forward<_Up>(__u))
+ {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args, size_t... _Indexes>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
+ __tuple_indices<_Indexes...>)
+ : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+ _LIBCPP_INLINE_VISIBILITY
+ const_reference __get() const _NOEXCEPT { return *this; }
+};
+
+template <class _T1, class _T2>
+class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
+ private __compressed_pair_elem<_T2, 1> {
+public:
+ // NOTE: This static assert should never fire because __compressed_pair
+ // is *almost never* used in a scenario where it's possible for T1 == T2.
+ // (The exception is std::function where it is possible that the function
+ // object and the allocator have the same type).
+ static_assert((!is_same<_T1, _T2>::value),
+ "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
+ "The current implementation is NOT ABI-compatible with the previous "
+ "implementation for this configuration");
+
+ typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1;
+ typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2;
+
+ template <bool _Dummy = true,
+ class = typename enable_if<
+ __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
+ __dependent_type<is_default_constructible<_T2>, _Dummy>::value
+ >::type
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
+
+ template <class _U1, class _U2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __compressed_pair(_U1&& __t1, _U2&& __t2)
+ : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args1, class... _Args2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
+ tuple<_Args2...> __second_args)
+ : _Base1(__pc, _VSTD::move(__first_args),
+ typename __make_tuple_indices<sizeof...(_Args1)>::type()),
+ _Base2(__pc, _VSTD::move(__second_args),
+ typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename _Base1::reference first() _NOEXCEPT {
+ return static_cast<_Base1&>(*this).__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename _Base1::const_reference first() const _NOEXCEPT {
+ return static_cast<_Base1 const&>(*this).__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename _Base2::reference second() _NOEXCEPT {
+ return static_cast<_Base2&>(*this).__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename _Base2::const_reference second() const _NOEXCEPT {
+ return static_cast<_Base2 const&>(*this).__get();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
+ return static_cast<_Base1*>(__pair);
+ }
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
+ return static_cast<_Base2*>(__pair);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(__compressed_pair& __x)
+ _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+ __is_nothrow_swappable<_T2>::value)
+ {
+ using _VSTD::swap;
+ swap(first(), __x.first());
+ swap(second(), __x.second());
+ }
+};
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
+ _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+ __is_nothrow_swappable<_T2>::value) {
+ __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/construct_at.h b/contrib/llvm-project/libcxx/include/__memory/construct_at.h
new file mode 100644
index 000000000000..7ab19315dcd8
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/construct_at.h
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H
+#define _LIBCPP___MEMORY_CONSTRUCT_AT_H
+
+#include <__config>
+#include <__debug>
+#include <__utility/forward.h>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// construct_at
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _Tp, class ..._Args, class = decltype(
+ ::new (declval<void*>()) _Tp(declval<_Args>()...)
+)>
+_LIBCPP_INLINE_VISIBILITY
+constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) {
+ _LIBCPP_ASSERT(__location, "null pointer given to construct_at");
+ return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
+}
+
+#endif
+
+// destroy_at
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy_at(_Tp* __loc) {
+ _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+ __loc->~_Tp();
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/pointer_safety.h b/contrib/llvm-project/libcxx/include/__memory/pointer_safety.h
new file mode 100644
index 000000000000..87a6a9659e0c
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/pointer_safety.h
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_POINTER_SAFETY_H
+#define _LIBCPP___MEMORY_POINTER_SAFETY_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+enum class pointer_safety : unsigned char {
+ relaxed,
+ preferred,
+ strict
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+pointer_safety get_pointer_safety() _NOEXCEPT {
+ return pointer_safety::relaxed;
+}
+
+_LIBCPP_FUNC_VIS void declare_reachable(void* __p);
+_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n);
+_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n);
+_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p);
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+undeclare_reachable(_Tp* __p)
+{
+ return static_cast<_Tp*>(__undeclare_reachable(__p));
+}
+
+#endif // !C++03
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_POINTER_SAFETY_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h b/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h
index b2c5d34cb082..d5442b84e2aa 100644
--- a/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h
+++ b/contrib/llvm-project/libcxx/include/__memory/pointer_traits.h
@@ -11,6 +11,7 @@
#define _LIBCPP___MEMORY_POINTER_TRAITS_H
#include <__config>
+#include <__memory/addressof.h>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -120,7 +121,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
#else
template <class _Up> struct rebind
{typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
private:
struct __nat {};
@@ -162,8 +163,54 @@ struct __rebind_pointer {
#endif
};
+// to_address
+
+template <class _Pointer, class = void>
+struct __to_address_helper;
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_Tp* __to_address(_Tp* __p) _NOEXCEPT {
+ static_assert(!is_function<_Tp>::value, "_Tp is a function type");
+ return __p;
+}
+
+// enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers
+template <class _Pointer, class = _EnableIf<!is_pointer<_Pointer>::value> >
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type
+__to_address(const _Pointer& __p) _NOEXCEPT {
+ return __to_address_helper<_Pointer>::__call(__p);
+}
+
+template <class _Pointer, class>
+struct __to_address_helper {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ static decltype(_VSTD::__to_address(declval<const _Pointer&>().operator->()))
+ __call(const _Pointer&__p) _NOEXCEPT {
+ return _VSTD::__to_address(__p.operator->());
+ }
+};
+
+template <class _Pointer>
+struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))> {
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ static decltype(pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
+ __call(const _Pointer&__p) _NOEXCEPT {
+ return pointer_traits<_Pointer>::to_address(__p);
+ }
+};
+
+#if _LIBCPP_STD_VER > 17
+template <class _Pointer>
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+auto to_address(const _Pointer& __p) noexcept {
+ return _VSTD::__to_address(__p);
+}
+#endif
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___MEMORY_POINTER_TRAITS_H
+#endif // _LIBCPP___MEMORY_POINTER_TRAITS_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/raw_storage_iterator.h b/contrib/llvm-project/libcxx/include/__memory/raw_storage_iterator.h
new file mode 100644
index 000000000000..e8f82b219e67
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/raw_storage_iterator.h
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
+#define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <cstddef>
+#include <iterator>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _OutputIterator, class _Tp>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator
+#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
+ : public iterator<output_iterator_tag, void, void, void, void>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+private:
+ _OutputIterator __x_;
+public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+#if _LIBCPP_STD_VER > 17
+ typedef ptrdiff_t difference_type;
+#else
+ typedef void difference_type;
+#endif
+ typedef void pointer;
+ typedef void reference;
+
+ _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
+ _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
+ _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
+ {::new ((void*)_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
+#if _LIBCPP_STD_VER >= 14
+ _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
+ {::new ((void*)_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
+#endif
+ _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
+ _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
+ {raw_storage_iterator __t(*this); ++__x_; return __t;}
+#if _LIBCPP_STD_VER >= 14
+ _LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; }
+#endif
+};
+
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/shared_ptr.h b/contrib/llvm-project/libcxx/include/__memory/shared_ptr.h
new file mode 100644
index 000000000000..04161c4b73ed
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/shared_ptr.h
@@ -0,0 +1,1879 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_SHARED_PTR_H
+#define _LIBCPP___MEMORY_SHARED_PTR_H
+
+#include <__availability>
+#include <__config>
+#include <__functional_base>
+#include <__functional/binary_function.h>
+#include <__functional/operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__memory/addressof.h>
+#include <__memory/allocation_guard.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/allocator.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/unique_ptr.h>
+#include <__utility/forward.h>
+#include <cstddef>
+#include <cstdlib> // abort
+#include <iosfwd>
+#include <stdexcept>
+#include <typeinfo>
+#include <type_traits>
+#include <utility>
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+# include <atomic>
+#endif
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+# include <__memory/auto_ptr.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Alloc>
+class __allocator_destructor
+{
+ typedef _LIBCPP_NODEBUG_TYPE allocator_traits<_Alloc> __alloc_traits;
+public:
+ typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::pointer pointer;
+ typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::size_type size_type;
+private:
+ _Alloc& __alloc_;
+ size_type __s_;
+public:
+ _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s)
+ _NOEXCEPT
+ : __alloc_(__a), __s_(__s) {}
+ _LIBCPP_INLINE_VISIBILITY
+ void operator()(pointer __p) _NOEXCEPT
+ {__alloc_traits::deallocate(__alloc_, __p, __s_);}
+};
+
+// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
+// should be sufficient for thread safety.
+// See https://llvm.org/PR22803
+#if defined(__clang__) && __has_builtin(__atomic_add_fetch) \
+ && defined(__ATOMIC_RELAXED) \
+ && defined(__ATOMIC_ACQ_REL)
+# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
+#elif defined(_LIBCPP_COMPILER_GCC)
+# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
+#endif
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+ defined(__ATOMIC_RELAXED) && \
+ (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
+ return __atomic_load_n(__value, __ATOMIC_RELAXED);
+#else
+ return *__value;
+#endif
+}
+
+template <class _ValueType>
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_acquire_load(_ValueType const* __value) {
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+ defined(__ATOMIC_ACQUIRE) && \
+ (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
+ return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
+#else
+ return *__value;
+#endif
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _Tp
+__libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
+ return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED);
+#else
+ return __t += 1;
+#endif
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _Tp
+__libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT
+{
+#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
+ return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL);
+#else
+ return __t -= 1;
+#endif
+}
+
+class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
+ : public std::exception
+{
+public:
+ bad_weak_ptr() _NOEXCEPT = default;
+ bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;
+ virtual ~bad_weak_ptr() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_bad_weak_ptr()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw bad_weak_ptr();
+#else
+ _VSTD::abort();
+#endif
+}
+
+template<class _Tp> class _LIBCPP_TEMPLATE_VIS weak_ptr;
+
+class _LIBCPP_TYPE_VIS __shared_count
+{
+ __shared_count(const __shared_count&);
+ __shared_count& operator=(const __shared_count&);
+
+protected:
+ long __shared_owners_;
+ virtual ~__shared_count();
+private:
+ virtual void __on_zero_shared() _NOEXCEPT = 0;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __shared_count(long __refs = 0) _NOEXCEPT
+ : __shared_owners_(__refs) {}
+
+#if defined(_LIBCPP_BUILDING_LIBRARY) && \
+ defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+ void __add_shared() _NOEXCEPT;
+ bool __release_shared() _NOEXCEPT;
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_shared() _NOEXCEPT {
+ __libcpp_atomic_refcount_increment(__shared_owners_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ bool __release_shared() _NOEXCEPT {
+ if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
+ __on_zero_shared();
+ return true;
+ }
+ return false;
+ }
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ long use_count() const _NOEXCEPT {
+ return __libcpp_relaxed_load(&__shared_owners_) + 1;
+ }
+};
+
+class _LIBCPP_TYPE_VIS __shared_weak_count
+ : private __shared_count
+{
+ long __shared_weak_owners_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
+ : __shared_count(__refs),
+ __shared_weak_owners_(__refs) {}
+protected:
+ virtual ~__shared_weak_count();
+
+public:
+#if defined(_LIBCPP_BUILDING_LIBRARY) && \
+ defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
+ void __add_shared() _NOEXCEPT;
+ void __add_weak() _NOEXCEPT;
+ void __release_shared() _NOEXCEPT;
+#else
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_shared() _NOEXCEPT {
+ __shared_count::__add_shared();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __add_weak() _NOEXCEPT {
+ __libcpp_atomic_refcount_increment(__shared_weak_owners_);
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ void __release_shared() _NOEXCEPT {
+ if (__shared_count::__release_shared())
+ __release_weak();
+ }
+#endif
+ void __release_weak() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ long use_count() const _NOEXCEPT {return __shared_count::use_count();}
+ __shared_weak_count* lock() _NOEXCEPT;
+
+ virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
+private:
+ virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
+};
+
+template <class _Tp, class _Dp, class _Alloc>
+class __shared_ptr_pointer
+ : public __shared_weak_count
+{
+ __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_;
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
+ : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}
+
+#ifndef _LIBCPP_NO_RTTI
+ virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
+#endif
+
+private:
+ virtual void __on_zero_shared() _NOEXCEPT;
+ virtual void __on_zero_shared_weak() _NOEXCEPT;
+};
+
+#ifndef _LIBCPP_NO_RTTI
+
+template <class _Tp, class _Dp, class _Alloc>
+const void*
+__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT
+{
+ return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : nullptr;
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template <class _Tp, class _Dp, class _Alloc>
+void
+__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT
+{
+ __data_.first().second()(__data_.first().first());
+ __data_.first().second().~_Dp();
+}
+
+template <class _Tp, class _Dp, class _Alloc>
+void
+__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
+{
+ typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al;
+ typedef allocator_traits<_Al> _ATraits;
+ typedef pointer_traits<typename _ATraits::pointer> _PTraits;
+
+ _Al __a(__data_.second());
+ __data_.second().~_Alloc();
+ __a.deallocate(_PTraits::pointer_to(*this), 1);
+}
+
+template <class _Tp, class _Alloc>
+struct __shared_ptr_emplace
+ : __shared_weak_count
+{
+ template<class ..._Args>
+ _LIBCPP_HIDE_FROM_ABI
+ explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
+ : __storage_(_VSTD::move(__a))
+ {
+#if _LIBCPP_STD_VER > 17
+ using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
+ _TpAlloc __tmp(*__get_alloc());
+ allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), _VSTD::forward<_Args>(__args)...);
+#else
+ ::new ((void*)__get_elem()) _Tp(_VSTD::forward<_Args>(__args)...);
+#endif
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
+
+private:
+ virtual void __on_zero_shared() _NOEXCEPT {
+#if _LIBCPP_STD_VER > 17
+ using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
+ _TpAlloc __tmp(*__get_alloc());
+ allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem());
+#else
+ __get_elem()->~_Tp();
+#endif
+ }
+
+ virtual void __on_zero_shared_weak() _NOEXCEPT {
+ using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
+ using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
+ _ControlBlockAlloc __tmp(*__get_alloc());
+ __storage_.~_Storage();
+ allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
+ pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
+ }
+
+ // This class implements the control block for non-array shared pointers created
+ // through `std::allocate_shared` and `std::make_shared`.
+ //
+ // In previous versions of the library, we used a compressed pair to store
+ // both the _Alloc and the _Tp. This implies using EBO, which is incompatible
+ // with Allocator construction for _Tp. To allow implementing P0674 in C++20,
+ // we now use a properly aligned char buffer while making sure that we maintain
+ // the same layout that we had when we used a compressed pair.
+ using _CompressedPair = __compressed_pair<_Alloc, _Tp>;
+ struct _ALIGNAS_TYPE(_CompressedPair) _Storage {
+ char __blob_[sizeof(_CompressedPair)];
+
+ _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) {
+ ::new ((void*)__get_alloc()) _Alloc(_VSTD::move(__a));
+ }
+ _LIBCPP_HIDE_FROM_ABI ~_Storage() {
+ __get_alloc()->~_Alloc();
+ }
+ _Alloc* __get_alloc() _NOEXCEPT {
+ _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
+ typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair);
+ _Alloc *__alloc = reinterpret_cast<_Alloc*>(__first);
+ return __alloc;
+ }
+ _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT {
+ _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
+ typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair);
+ _Tp *__elem = reinterpret_cast<_Tp*>(__second);
+ return __elem;
+ }
+ };
+
+ static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), "");
+ static_assert(sizeof(_Storage) == sizeof(_CompressedPair), "");
+ _Storage __storage_;
+};
+
+struct __shared_ptr_dummy_rebind_allocator_type;
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{
+public:
+ template <class _Other>
+ struct rebind
+ {
+ typedef allocator<_Other> other;
+ };
+};
+
+template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
+
+template<class _Tp, class _Up>
+struct __compatible_with
+#if _LIBCPP_STD_VER > 14
+ : is_convertible<remove_extent_t<_Tp>*, remove_extent_t<_Up>*> {};
+#else
+ : is_convertible<_Tp*, _Up*> {};
+#endif // _LIBCPP_STD_VER > 14
+
+template <class _Ptr, class = void>
+struct __is_deletable : false_type { };
+template <class _Ptr>
+struct __is_deletable<_Ptr, decltype(delete declval<_Ptr>())> : true_type { };
+
+template <class _Ptr, class = void>
+struct __is_array_deletable : false_type { };
+template <class _Ptr>
+struct __is_array_deletable<_Ptr, decltype(delete[] declval<_Ptr>())> : true_type { };
+
+template <class _Dp, class _Pt,
+ class = decltype(declval<_Dp>()(declval<_Pt>()))>
+static true_type __well_formed_deleter_test(int);
+
+template <class, class>
+static false_type __well_formed_deleter_test(...);
+
+template <class _Dp, class _Pt>
+struct __well_formed_deleter : decltype(__well_formed_deleter_test<_Dp, _Pt>(0)) {};
+
+template<class _Dp, class _Tp, class _Yp>
+struct __shared_ptr_deleter_ctor_reqs
+{
+ static const bool value = __compatible_with<_Tp, _Yp>::value &&
+ is_move_constructible<_Dp>::value &&
+ __well_formed_deleter<_Dp, _Tp*>::value;
+};
+
+#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
+# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
+#else
+# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI
+#endif
+
+template<class _Tp>
+class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr
+{
+public:
+#if _LIBCPP_STD_VER > 14
+ typedef weak_ptr<_Tp> weak_type;
+ typedef remove_extent_t<_Tp> element_type;
+#else
+ typedef _Tp element_type;
+#endif
+
+private:
+ element_type* __ptr_;
+ __shared_weak_count* __cntrl_;
+
+ struct __nat {int __for_bool_;};
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
+
+ template<class _Yp, class = _EnableIf<
+ _And<
+ __compatible_with<_Yp, _Tp>
+ // In C++03 we get errors when trying to do SFINAE with the
+ // delete operator, so we always pretend that it's deletable.
+ // The same happens on GCC.
+#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC)
+ , _If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> >
+#endif
+ >::value
+ > >
+ explicit shared_ptr(_Yp* __p) : __ptr_(__p) {
+ unique_ptr<_Yp> __hold(__p);
+ typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+ typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT > _CntrlBlk;
+ __cntrl_ = new _CntrlBlk(__p, __shared_ptr_default_delete<_Tp, _Yp>(), _AllocT());
+ __hold.release();
+ __enable_weak_this(__p, __p);
+ }
+
+ template<class _Yp, class _Dp>
+ shared_ptr(_Yp* __p, _Dp __d,
+ typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type = __nat());
+ template<class _Yp, class _Dp, class _Alloc>
+ shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
+ typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type = __nat());
+ template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
+ template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
+ template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr(const shared_ptr& __r) _NOEXCEPT;
+ template<class _Yp>
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr(const shared_ptr<_Yp>& __r,
+ typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
+ _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr(shared_ptr&& __r) _NOEXCEPT;
+ template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r,
+ typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
+ _NOEXCEPT;
+ template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
+ typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat());
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+ template<class _Yp>
+ shared_ptr(auto_ptr<_Yp>&& __r,
+ typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
+#endif
+ template <class _Yp, class _Dp>
+ shared_ptr(unique_ptr<_Yp, _Dp>&&,
+ typename enable_if
+ <
+ !is_lvalue_reference<_Dp>::value &&
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+ __nat
+ >::type = __nat());
+ template <class _Yp, class _Dp>
+ shared_ptr(unique_ptr<_Yp, _Dp>&&,
+ typename enable_if
+ <
+ is_lvalue_reference<_Dp>::value &&
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+ __nat
+ >::type = __nat());
+
+ ~shared_ptr();
+
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
+ template<class _Yp>
+ typename enable_if
+ <
+ __compatible_with<_Yp, element_type>::value,
+ shared_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
+ template<class _Yp>
+ typename enable_if
+ <
+ __compatible_with<_Yp, element_type>::value,
+ shared_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(shared_ptr<_Yp>&& __r);
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+ template<class _Yp>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if
+ <
+ !is_array<_Yp>::value &&
+ is_convertible<_Yp*, element_type*>::value,
+ shared_ptr
+ >::type&
+ operator=(auto_ptr<_Yp>&& __r);
+#endif
+ template <class _Yp, class _Dp>
+ typename enable_if
+ <
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+ shared_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(unique_ptr<_Yp, _Dp>&& __r);
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(shared_ptr& __r) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() _NOEXCEPT;
+ template<class _Yp>
+ typename enable_if
+ <
+ __compatible_with<_Yp, element_type>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ reset(_Yp* __p);
+ template<class _Yp, class _Dp>
+ typename enable_if
+ <
+ __compatible_with<_Yp, element_type>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ reset(_Yp* __p, _Dp __d);
+ template<class _Yp, class _Dp, class _Alloc>
+ typename enable_if
+ <
+ __compatible_with<_Yp, element_type>::value,
+ void
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ reset(_Yp* __p, _Dp __d, _Alloc __a);
+
+ _LIBCPP_INLINE_VISIBILITY
+ element_type* get() const _NOEXCEPT {return __ptr_;}
+ _LIBCPP_INLINE_VISIBILITY
+ typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
+ {return *__ptr_;}
+ _LIBCPP_INLINE_VISIBILITY
+ element_type* operator->() const _NOEXCEPT
+ {
+ static_assert(!is_array<_Tp>::value,
+ "std::shared_ptr<T>::operator-> is only valid when T is not an array type.");
+ return __ptr_;
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool unique() const _NOEXCEPT {return use_count() == 1;}
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {return get() != nullptr;}
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT
+ {return __cntrl_ < __p.__cntrl_;}
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT
+ {return __cntrl_ < __p.__cntrl_;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool
+ __owner_equivalent(const shared_ptr& __p) const
+ {return __cntrl_ == __p.__cntrl_;}
+
+#if _LIBCPP_STD_VER > 14
+ typename add_lvalue_reference<element_type>::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator[](ptrdiff_t __i) const
+ {
+ static_assert(is_array<_Tp>::value,
+ "std::shared_ptr<T>::operator[] is only valid when T is an array type.");
+ return __ptr_[__i];
+ }
+#endif
+
+#ifndef _LIBCPP_NO_RTTI
+ template <class _Dp>
+ _LIBCPP_INLINE_VISIBILITY
+ _Dp* __get_deleter() const _NOEXCEPT
+ {return static_cast<_Dp*>(__cntrl_
+ ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp)))
+ : nullptr);}
+#endif // _LIBCPP_NO_RTTI
+
+ template<class _Yp, class _CntrlBlk>
+ static shared_ptr<_Tp>
+ __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT
+ {
+ shared_ptr<_Tp> __r;
+ __r.__ptr_ = __p;
+ __r.__cntrl_ = __cntrl;
+ __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
+ return __r;
+ }
+
+private:
+ template <class _Yp, bool = is_function<_Yp>::value>
+ struct __shared_ptr_default_allocator
+ {
+ typedef allocator<_Yp> type;
+ };
+
+ template <class _Yp>
+ struct __shared_ptr_default_allocator<_Yp, true>
+ {
+ typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type;
+ };
+
+ template <class _Yp, class _OrigPtr>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<is_convertible<_OrigPtr*,
+ const enable_shared_from_this<_Yp>*
+ >::value,
+ void>::type
+ __enable_weak_this(const enable_shared_from_this<_Yp>* __e,
+ _OrigPtr* __ptr) _NOEXCEPT
+ {
+ typedef typename remove_cv<_Yp>::type _RawYp;
+ if (__e && __e->__weak_this_.expired())
+ {
+ __e->__weak_this_ = shared_ptr<_RawYp>(*this,
+ const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr)));
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}
+
+ template <class, class _Yp>
+ struct __shared_ptr_default_delete
+ : default_delete<_Yp> {};
+
+ template <class _Yp, class _Un, size_t _Sz>
+ struct __shared_ptr_default_delete<_Yp[_Sz], _Un>
+ : default_delete<_Yp[]> {};
+
+ template <class _Yp, class _Un>
+ struct __shared_ptr_default_delete<_Yp[], _Un>
+ : default_delete<_Yp[]> {};
+
+ template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
+ template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
+};
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _Tp>
+shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>;
+template<class _Tp, class _Dp>
+shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>;
+#endif
+
+template<class _Tp>
+inline
+_LIBCPP_CONSTEXPR
+shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
+{
+}
+
+template<class _Tp>
+inline
+_LIBCPP_CONSTEXPR
+shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
+{
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp>
+shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
+ typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type)
+ : __ptr_(__p)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+ typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
+#ifndef _LIBCPP_CXX03_LANG
+ __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT());
+#else
+ __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
+#endif // not _LIBCPP_CXX03_LANG
+ __enable_weak_this(__p, __p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __d(__p);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Dp>
+shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
+ : __ptr_(nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
+ typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk;
+#ifndef _LIBCPP_CXX03_LANG
+ __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT());
+#else
+ __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
+#endif // not _LIBCPP_CXX03_LANG
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __d(__p);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp, class _Alloc>
+shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
+ typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type)
+ : __ptr_(__p)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
+ typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+ typedef __allocator_destructor<_A2> _D2;
+ _A2 __a2(__a);
+ unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+ ::new ((void*)_VSTD::addressof(*__hold2.get()))
+#ifndef _LIBCPP_CXX03_LANG
+ _CntrlBlk(__p, _VSTD::move(__d), __a);
+#else
+ _CntrlBlk(__p, __d, __a);
+#endif // not _LIBCPP_CXX03_LANG
+ __cntrl_ = _VSTD::addressof(*__hold2.release());
+ __enable_weak_this(__p, __p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __d(__p);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Dp, class _Alloc>
+shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
+ : __ptr_(nullptr)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
+ typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
+ typedef __allocator_destructor<_A2> _D2;
+ _A2 __a2(__a);
+ unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+ ::new ((void*)_VSTD::addressof(*__hold2.get()))
+#ifndef _LIBCPP_CXX03_LANG
+ _CntrlBlk(__p, _VSTD::move(__d), __a);
+#else
+ _CntrlBlk(__p, __d, __a);
+#endif // not _LIBCPP_CXX03_LANG
+ __cntrl_ = _VSTD::addressof(*__hold2.release());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __d(__p);
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT
+ : __ptr_(__p),
+ __cntrl_(__r.__cntrl_)
+{
+ if (__cntrl_)
+ __cntrl_->__add_shared();
+}
+
+template<class _Tp>
+inline
+shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ if (__cntrl_)
+ __cntrl_->__add_shared();
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
+ typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
+ _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ if (__cntrl_)
+ __cntrl_->__add_shared();
+}
+
+template<class _Tp>
+inline
+shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
+ typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
+ _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
+}
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+template<class _Tp>
+template<class _Yp>
+shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
+ typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
+ : __ptr_(__r.get())
+{
+ typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
+ __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>());
+ __enable_weak_this(__r.get(), __r.get());
+ __r.release();
+}
+#endif
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
+ typename enable_if
+ <
+ !is_lvalue_reference<_Dp>::value &&
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+ __nat
+ >::type)
+ : __ptr_(__r.get())
+{
+#if _LIBCPP_STD_VER > 11
+ if (__ptr_ == nullptr)
+ __cntrl_ = nullptr;
+ else
+#endif
+ {
+ typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+ typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk;
+ __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT());
+ __enable_weak_this(__r.get(), __r.get());
+ }
+ __r.release();
+}
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
+ typename enable_if
+ <
+ is_lvalue_reference<_Dp>::value &&
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+ __nat
+ >::type)
+ : __ptr_(__r.get())
+{
+#if _LIBCPP_STD_VER > 11
+ if (__ptr_ == nullptr)
+ __cntrl_ = nullptr;
+ else
+#endif
+ {
+ typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+ typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
+ reference_wrapper<typename remove_reference<_Dp>::type>,
+ _AllocT > _CntrlBlk;
+ __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
+ __enable_weak_this(__r.get(), __r.get());
+ }
+ __r.release();
+}
+
+template<class _Tp>
+shared_ptr<_Tp>::~shared_ptr()
+{
+ if (__cntrl_)
+ __cntrl_->__release_shared();
+}
+
+template<class _Tp>
+inline
+shared_ptr<_Tp>&
+shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT
+{
+ shared_ptr(__r).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
+ shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
+{
+ shared_ptr(__r).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+inline
+shared_ptr<_Tp>&
+shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT
+{
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
+ shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)
+{
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+}
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ !is_array<_Yp>::value &&
+ is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value,
+ shared_ptr<_Tp>
+>::type&
+shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r)
+{
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+}
+#endif
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+inline
+typename enable_if
+<
+ is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
+ typename shared_ptr<_Tp>::element_type*>::value,
+ shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)
+{
+ shared_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+inline
+void
+shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT
+{
+ _VSTD::swap(__ptr_, __r.__ptr_);
+ _VSTD::swap(__cntrl_, __r.__cntrl_);
+}
+
+template<class _Tp>
+inline
+void
+shared_ptr<_Tp>::reset() _NOEXCEPT
+{
+ shared_ptr().swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
+ void
+>::type
+shared_ptr<_Tp>::reset(_Yp* __p)
+{
+ shared_ptr(__p).swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp>
+inline
+typename enable_if
+<
+ __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
+ void
+>::type
+shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d)
+{
+ shared_ptr(__p, __d).swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp, class _Alloc>
+inline
+typename enable_if
+<
+ __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
+ void
+>::type
+shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
+{
+ shared_ptr(__p, __d, __a).swap(*this);
+}
+
+//
+// std::allocate_shared and std::make_shared
+//
+template<class _Tp, class _Alloc, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& ...__args)
+{
+ using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
+ using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
+ __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);
+ ::new ((void*)_VSTD::addressof(*__guard.__get())) _ControlBlock(__a, _VSTD::forward<_Args>(__args)...);
+ auto __control_block = __guard.__release_ptr();
+ return shared_ptr<_Tp>::__create_with_control_block((*__control_block).__get_elem(), _VSTD::addressof(*__control_block));
+}
+
+template<class _Tp, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
+_LIBCPP_HIDE_FROM_ABI
+shared_ptr<_Tp> make_shared(_Args&& ...__args)
+{
+ return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+ return __x.get() == __y.get();
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+ return !(__x == __y);
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+#if _LIBCPP_STD_VER <= 11
+ typedef typename common_type<_Tp*, _Up*>::type _Vp;
+ return less<_Vp>()(__x.get(), __y.get());
+#else
+ return less<>()(__x.get(), __y.get());
+#endif
+
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+ return __y < __x;
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+ return !(__y < __x);
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+ return !(__x < __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+ return !__x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+ return !__x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+ return static_cast<bool>(__x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+ return static_cast<bool>(__x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+ return less<_Tp*>()(__x.get(), nullptr);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+ return less<_Tp*>()(nullptr, __x.get());
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+ return nullptr < __x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+ return __x < nullptr;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+ return !(nullptr < __x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+ return !(__x < nullptr);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+ return !(__x < nullptr);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+ return !(nullptr < __x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+ return shared_ptr<_Tp>(__r,
+ static_cast<
+ typename shared_ptr<_Tp>::element_type*>(__r.get()));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+ typedef typename shared_ptr<_Tp>::element_type _ET;
+ _ET* __p = dynamic_cast<_ET*>(__r.get());
+ return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>();
+}
+
+template<class _Tp, class _Up>
+shared_ptr<_Tp>
+const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+ typedef typename shared_ptr<_Tp>::element_type _RTp;
+ return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get()));
+}
+
+template<class _Tp, class _Up>
+shared_ptr<_Tp>
+reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+ return shared_ptr<_Tp>(__r,
+ reinterpret_cast<
+ typename shared_ptr<_Tp>::element_type*>(__r.get()));
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Dp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Dp*
+get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
+{
+ return __p.template __get_deleter<_Dp>();
+}
+
+#endif // _LIBCPP_NO_RTTI
+
+template<class _Tp>
+class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr
+{
+public:
+ typedef _Tp element_type;
+private:
+ element_type* __ptr_;
+ __shared_weak_count* __cntrl_;
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
+ template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r,
+ typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
+ _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr(weak_ptr const& __r) _NOEXCEPT;
+ template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r,
+ typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
+ _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr(weak_ptr&& __r) _NOEXCEPT;
+ template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,
+ typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
+ _NOEXCEPT;
+ ~weak_ptr();
+
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT;
+ template<class _Yp>
+ typename enable_if
+ <
+ is_convertible<_Yp*, element_type*>::value,
+ weak_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
+ template<class _Yp>
+ typename enable_if
+ <
+ is_convertible<_Yp*, element_type*>::value,
+ weak_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
+
+ template<class _Yp>
+ typename enable_if
+ <
+ is_convertible<_Yp*, element_type*>::value,
+ weak_ptr&
+ >::type
+ _LIBCPP_INLINE_VISIBILITY
+ operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(weak_ptr& __r) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ void reset() _NOEXCEPT;
+
+ _LIBCPP_INLINE_VISIBILITY
+ long use_count() const _NOEXCEPT
+ {return __cntrl_ ? __cntrl_->use_count() : 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ bool expired() const _NOEXCEPT
+ {return __cntrl_ == nullptr || __cntrl_->use_count() == 0;}
+ shared_ptr<_Tp> lock() const _NOEXCEPT;
+ template<class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT
+ {return __cntrl_ < __r.__cntrl_;}
+ template<class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT
+ {return __cntrl_ < __r.__cntrl_;}
+
+ template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
+ template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
+};
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _Tp>
+weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>;
+#endif
+
+template<class _Tp>
+inline
+_LIBCPP_CONSTEXPR
+weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
+ : __ptr_(nullptr),
+ __cntrl_(nullptr)
+{
+}
+
+template<class _Tp>
+inline
+weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ if (__cntrl_)
+ __cntrl_->__add_weak();
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
+ typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
+ _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ if (__cntrl_)
+ __cntrl_->__add_weak();
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
+ typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
+ _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ if (__cntrl_)
+ __cntrl_->__add_weak();
+}
+
+template<class _Tp>
+inline
+weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
+ typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
+ _NOEXCEPT
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_)
+{
+ __r.__ptr_ = nullptr;
+ __r.__cntrl_ = nullptr;
+}
+
+template<class _Tp>
+weak_ptr<_Tp>::~weak_ptr()
+{
+ if (__cntrl_)
+ __cntrl_->__release_weak();
+}
+
+template<class _Tp>
+inline
+weak_ptr<_Tp>&
+weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT
+{
+ weak_ptr(__r).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ is_convertible<_Yp*, _Tp*>::value,
+ weak_ptr<_Tp>&
+>::type
+weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
+{
+ weak_ptr(__r).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+inline
+weak_ptr<_Tp>&
+weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT
+{
+ weak_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ is_convertible<_Yp*, _Tp*>::value,
+ weak_ptr<_Tp>&
+>::type
+weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
+{
+ weak_ptr(_VSTD::move(__r)).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline
+typename enable_if
+<
+ is_convertible<_Yp*, _Tp*>::value,
+ weak_ptr<_Tp>&
+>::type
+weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT
+{
+ weak_ptr(__r).swap(*this);
+ return *this;
+}
+
+template<class _Tp>
+inline
+void
+weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT
+{
+ _VSTD::swap(__ptr_, __r.__ptr_);
+ _VSTD::swap(__cntrl_, __r.__cntrl_);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT
+{
+ __x.swap(__y);
+}
+
+template<class _Tp>
+inline
+void
+weak_ptr<_Tp>::reset() _NOEXCEPT
+{
+ weak_ptr().swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp>
+shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
+ typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
+ : __ptr_(__r.__ptr_),
+ __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
+{
+ if (__cntrl_ == nullptr)
+ __throw_bad_weak_ptr();
+}
+
+template<class _Tp>
+shared_ptr<_Tp>
+weak_ptr<_Tp>::lock() const _NOEXCEPT
+{
+ shared_ptr<_Tp> __r;
+ __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_;
+ if (__r.__cntrl_)
+ __r.__ptr_ = __ptr_;
+ return __r;
+}
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp = void> struct owner_less;
+#else
+template <class _Tp> struct owner_less;
+#endif
+
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> >
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> second_argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> >
+#if !defined(_LIBCPP_ABI_NO_BINDER_BASES)
+ : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
+#endif
+{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> second_argument_type;
+#endif
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+};
+
+#if _LIBCPP_STD_VER > 14
+template <>
+struct _LIBCPP_TEMPLATE_VIS owner_less<void>
+{
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ template <class _Tp, class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT
+ {return __x.owner_before(__y);}
+ typedef void is_transparent;
+};
+#endif
+
+template<class _Tp>
+class _LIBCPP_TEMPLATE_VIS enable_shared_from_this
+{
+ mutable weak_ptr<_Tp> __weak_this_;
+protected:
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ enable_shared_from_this() _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY
+ enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY
+ enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT
+ {return *this;}
+ _LIBCPP_INLINE_VISIBILITY
+ ~enable_shared_from_this() {}
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr<_Tp> shared_from_this()
+ {return shared_ptr<_Tp>(__weak_this_);}
+ _LIBCPP_INLINE_VISIBILITY
+ shared_ptr<_Tp const> shared_from_this() const
+ {return shared_ptr<const _Tp>(__weak_this_);}
+
+#if _LIBCPP_STD_VER > 14
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr<_Tp> weak_from_this() _NOEXCEPT
+ { return __weak_this_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT
+ { return __weak_this_; }
+#endif // _LIBCPP_STD_VER > 14
+
+ template <class _Up> friend class shared_ptr;
+};
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> >
+{
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const shared_ptr<_Tp>& __ptr) const _NOEXCEPT
+ {
+ return hash<typename shared_ptr<_Tp>::element_type*>()(__ptr.get());
+ }
+};
+
+template<class _CharT, class _Traits, class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
+
+
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+
+class _LIBCPP_TYPE_VIS __sp_mut
+{
+ void* __lx;
+public:
+ void lock() _NOEXCEPT;
+ void unlock() _NOEXCEPT;
+
+private:
+ _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT;
+ __sp_mut(const __sp_mut&);
+ __sp_mut& operator=(const __sp_mut&);
+
+ friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*);
+};
+
+_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+__sp_mut& __get_sp_mut(const void*);
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_is_lock_free(const shared_ptr<_Tp>*)
+{
+ return false;
+}
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+shared_ptr<_Tp>
+atomic_load(const shared_ptr<_Tp>* __p)
+{
+ __sp_mut& __m = __get_sp_mut(__p);
+ __m.lock();
+ shared_ptr<_Tp> __q = *__p;
+ __m.unlock();
+ return __q;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+shared_ptr<_Tp>
+atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
+{
+ return atomic_load(__p);
+}
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+void
+atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
+{
+ __sp_mut& __m = __get_sp_mut(__p);
+ __m.lock();
+ __p->swap(__r);
+ __m.unlock();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+void
+atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
+{
+ atomic_store(__p, __r);
+}
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+shared_ptr<_Tp>
+atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
+{
+ __sp_mut& __m = __get_sp_mut(__p);
+ __m.lock();
+ __p->swap(__r);
+ __m.unlock();
+ return __r;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+shared_ptr<_Tp>
+atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
+{
+ return atomic_exchange(__p, __r);
+}
+
+template <class _Tp>
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+bool
+atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
+{
+ shared_ptr<_Tp> __temp;
+ __sp_mut& __m = __get_sp_mut(__p);
+ __m.lock();
+ if (__p->__owner_equivalent(*__v))
+ {
+ _VSTD::swap(__temp, *__p);
+ *__p = __w;
+ __m.unlock();
+ return true;
+ }
+ _VSTD::swap(__temp, *__v);
+ *__v = *__p;
+ __m.unlock();
+ return false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+bool
+atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
+{
+ return atomic_compare_exchange_strong(__p, __v, __w);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+bool
+atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
+ shared_ptr<_Tp> __w, memory_order, memory_order)
+{
+ return atomic_compare_exchange_strong(__p, __v, __w);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+bool
+atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
+ shared_ptr<_Tp> __w, memory_order, memory_order)
+{
+ return atomic_compare_exchange_weak(__p, __v, __w);
+}
+
+#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_SHARED_PTR_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h b/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h
new file mode 100644
index 000000000000..6d1884f722b0
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/temporary_buffer.h
@@ -0,0 +1,89 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
+#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
+
+#include <__config>
+#include <cstddef>
+#include <new>
+#include <utility> // pair
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI
+pair<_Tp*, ptrdiff_t>
+get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
+{
+ pair<_Tp*, ptrdiff_t> __r(0, 0);
+ const ptrdiff_t __m = (~ptrdiff_t(0) ^
+ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1)))
+ / sizeof(_Tp);
+ if (__n > __m)
+ __n = __m;
+ while (__n > 0)
+ {
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+ if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))
+ {
+ align_val_t __al =
+ align_val_t(alignment_of<_Tp>::value);
+ __r.first = static_cast<_Tp*>(::operator new(
+ __n * sizeof(_Tp), __al, nothrow));
+ } else {
+ __r.first = static_cast<_Tp*>(::operator new(
+ __n * sizeof(_Tp), nothrow));
+ }
+#else
+ if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))
+ {
+ // Since aligned operator new is unavailable, return an empty
+ // buffer rather than one with invalid alignment.
+ return __r;
+ }
+
+ __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
+#endif
+
+ if (__r.first)
+ {
+ __r.second = __n;
+ break;
+ }
+ __n /= 2;
+ }
+ return __r;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void return_temporary_buffer(_Tp* __p) _NOEXCEPT
+{
+ _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));
+}
+
+struct __return_temporary_buffer
+{
+ template <class _Tp>
+ _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
new file mode 100644
index 000000000000..39edabbd8e4f
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/uninitialized_algorithms.h
@@ -0,0 +1,261 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
+#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <__memory/construct_at.h>
+#include <iterator>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _ForwardIterator>
+_ForwardIterator
+uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ _ForwardIterator __s = __r;
+ try
+ {
+#endif
+ for (; __f != __l; ++__f, (void) ++__r)
+ ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (; __s != __r; ++__s)
+ __s->~value_type();
+ throw;
+ }
+#endif
+ return __r;
+}
+
+template <class _InputIterator, class _Size, class _ForwardIterator>
+_ForwardIterator
+uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ _ForwardIterator __s = __r;
+ try
+ {
+#endif
+ for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
+ ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (; __s != __r; ++__s)
+ __s->~value_type();
+ throw;
+ }
+#endif
+ return __r;
+}
+
+template <class _ForwardIterator, class _Tp>
+void
+uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ _ForwardIterator __s = __f;
+ try
+ {
+#endif
+ for (; __f != __l; ++__f)
+ ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (; __s != __f; ++__s)
+ __s->~value_type();
+ throw;
+ }
+#endif
+}
+
+template <class _ForwardIterator, class _Size, class _Tp>
+_ForwardIterator
+uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
+{
+ typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ _ForwardIterator __s = __f;
+ try
+ {
+#endif
+ for (; __n > 0; ++__f, (void) --__n)
+ ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ for (; __s != __f; ++__s)
+ __s->~value_type();
+ throw;
+ }
+#endif
+ return __f;
+}
+
+#if _LIBCPP_STD_VER > 14
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+void destroy(_ForwardIterator __first, _ForwardIterator __last) {
+ for (; __first != __last; ++__first)
+ _VSTD::destroy_at(_VSTD::addressof(*__first));
+}
+
+template <class _ForwardIterator, class _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
+ for (; __n > 0; (void)++__first, --__n)
+ _VSTD::destroy_at(_VSTD::addressof(*__first));
+ return __first;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
+ using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __idx != __last; ++__idx)
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::destroy(__first, __idx);
+ throw;
+ }
+#endif
+}
+
+template <class _ForwardIterator, class _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
+ using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0; (void)++__idx, --__n)
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
+ return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::destroy(__first, __idx);
+ throw;
+ }
+#endif
+}
+
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
+ using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __idx != __last; ++__idx)
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::destroy(__first, __idx);
+ throw;
+ }
+#endif
+}
+
+template <class _ForwardIterator, class _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
+ using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
+ auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0; (void)++__idx, --__n)
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
+ return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::destroy(__first, __idx);
+ throw;
+ }
+#endif
+}
+
+
+template <class _InputIt, class _ForwardIt>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __first_res) {
+ using _Vt = typename iterator_traits<_ForwardIt>::value_type;
+ auto __idx = __first_res;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __first != __last; (void)++__idx, ++__first)
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
+ return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::destroy(__first_res, __idx);
+ throw;
+ }
+#endif
+}
+
+template <class _InputIt, class _Size, class _ForwardIt>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_InputIt, _ForwardIt>
+uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
+ using _Vt = typename iterator_traits<_ForwardIt>::value_type;
+ auto __idx = __first_res;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try {
+#endif
+ for (; __n > 0; ++__idx, (void)++__first, --__n)
+ ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
+ return {__first, __idx};
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ } catch (...) {
+ _VSTD::destroy(__first_res, __idx);
+ throw;
+ }
+#endif
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h b/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h
new file mode 100644
index 000000000000..083e0a8c250d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/unique_ptr.h
@@ -0,0 +1,773 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H
+#define _LIBCPP___MEMORY_UNIQUE_PTR_H
+
+#include <__config>
+#include <__functional_base>
+#include <__functional/hash.h>
+#include <__functional/operations.h>
+#include <__memory/allocator_traits.h> // __pointer
+#include <__memory/compressed_pair.h>
+#include <__utility/forward.h>
+#include <cstddef>
+#include <type_traits>
+#include <utility>
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+# include <__memory/auto_ptr.h>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS default_delete {
+ static_assert(!is_function<_Tp>::value,
+ "default_delete cannot be instantiated for function types");
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY constexpr default_delete() _NOEXCEPT = default;
+#else
+ _LIBCPP_INLINE_VISIBILITY default_delete() {}
+#endif
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ default_delete(const default_delete<_Up>&,
+ typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* =
+ 0) _NOEXCEPT {}
+
+ _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {
+ static_assert(sizeof(_Tp) > 0,
+ "default_delete can not delete incomplete type");
+ static_assert(!is_void<_Tp>::value,
+ "default_delete can not delete incomplete type");
+ delete __ptr;
+ }
+};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> {
+private:
+ template <class _Up>
+ struct _EnableIfConvertible
+ : enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value> {};
+
+public:
+#ifndef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY constexpr default_delete() _NOEXCEPT = default;
+#else
+ _LIBCPP_INLINE_VISIBILITY default_delete() {}
+#endif
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ default_delete(const default_delete<_Up[]>&,
+ typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
+
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ typename _EnableIfConvertible<_Up>::type
+ operator()(_Up* __ptr) const _NOEXCEPT {
+ static_assert(sizeof(_Tp) > 0,
+ "default_delete can not delete incomplete type");
+ static_assert(!is_void<_Tp>::value,
+ "default_delete can not delete void type");
+ delete[] __ptr;
+ }
+};
+
+template <class _Deleter>
+struct __unique_ptr_deleter_sfinae {
+ static_assert(!is_reference<_Deleter>::value, "incorrect specialization");
+ typedef const _Deleter& __lval_ref_type;
+ typedef _Deleter&& __good_rval_ref_type;
+ typedef true_type __enable_rval_overload;
+};
+
+template <class _Deleter>
+struct __unique_ptr_deleter_sfinae<_Deleter const&> {
+ typedef const _Deleter& __lval_ref_type;
+ typedef const _Deleter&& __bad_rval_ref_type;
+ typedef false_type __enable_rval_overload;
+};
+
+template <class _Deleter>
+struct __unique_ptr_deleter_sfinae<_Deleter&> {
+ typedef _Deleter& __lval_ref_type;
+ typedef _Deleter&& __bad_rval_ref_type;
+ typedef false_type __enable_rval_overload;
+};
+
+#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)
+# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
+#else
+# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI
+#endif
+
+template <class _Tp, class _Dp = default_delete<_Tp> >
+class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
+public:
+ typedef _Tp element_type;
+ typedef _Dp deleter_type;
+ typedef _LIBCPP_NODEBUG_TYPE typename __pointer<_Tp, deleter_type>::type pointer;
+
+ static_assert(!is_rvalue_reference<deleter_type>::value,
+ "the specified deleter type cannot be an rvalue reference");
+
+private:
+ __compressed_pair<pointer, deleter_type> __ptr_;
+
+ struct __nat { int __for_bool_; };
+
+ typedef _LIBCPP_NODEBUG_TYPE __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
+
+ template <bool _Dummy>
+ using _LValRefType _LIBCPP_NODEBUG_TYPE =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
+
+ template <bool _Dummy>
+ using _GoodRValRefType _LIBCPP_NODEBUG_TYPE =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
+
+ template <bool _Dummy>
+ using _BadRValRefType _LIBCPP_NODEBUG_TYPE =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
+
+ template <bool _Dummy, class _Deleter = typename __dependent_type<
+ __identity<deleter_type>, _Dummy>::type>
+ using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE =
+ typename enable_if<is_default_constructible<_Deleter>::value &&
+ !is_pointer<_Deleter>::value>::type;
+
+ template <class _ArgType>
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE =
+ typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
+
+ template <class _UPtr, class _Up>
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
+ is_convertible<typename _UPtr::pointer, pointer>::value &&
+ !is_array<_Up>::value
+ >::type;
+
+ template <class _UDel>
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
+ (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
+ (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
+ >::type;
+
+ template <class _UDel>
+ using _EnableIfDeleterAssignable = typename enable_if<
+ is_assignable<_Dp&, _UDel&&>::value
+ >::type;
+
+public:
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __default_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(__p, __d) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(__p, _VSTD::move(__d)) {
+ static_assert(!is_reference<deleter_type>::value,
+ "rvalue deleter bound to reference");
+ }
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(unique_ptr&& __u) _NOEXCEPT
+ : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
+ }
+
+ template <class _Up, class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterConvertible<_Ep>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
+ : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(auto_ptr<_Up>&& __p,
+ typename enable_if<is_convertible<_Up*, _Tp*>::value &&
+ is_same<_Dp, default_delete<_Tp> >::value,
+ __nat>::type = __nat()) _NOEXCEPT
+ : __ptr_(__p.release(), __default_init_tag()) {}
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
+ reset(__u.release());
+ __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
+ return *this;
+ }
+
+ template <class _Up, class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterAssignable<_Ep>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
+ reset(__u.release());
+ __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
+ return *this;
+ }
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+ template <class _Up>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<is_convertible<_Up*, _Tp*>::value &&
+ is_same<_Dp, default_delete<_Tp> >::value,
+ unique_ptr&>::type
+ operator=(auto_ptr<_Up> __p) {
+ reset(__p.release());
+ return *this;
+ }
+#endif
+
+#ifdef _LIBCPP_CXX03_LANG
+ unique_ptr(unique_ptr const&) = delete;
+ unique_ptr& operator=(unique_ptr const&) = delete;
+#endif
+
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~unique_ptr() { reset(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr& operator=(nullptr_t) _NOEXCEPT {
+ reset();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename add_lvalue_reference<_Tp>::type
+ operator*() const {
+ return *__ptr_.first();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ pointer operator->() const _NOEXCEPT {
+ return __ptr_.first();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ pointer get() const _NOEXCEPT {
+ return __ptr_.first();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ deleter_type& get_deleter() _NOEXCEPT {
+ return __ptr_.second();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ const deleter_type& get_deleter() const _NOEXCEPT {
+ return __ptr_.second();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {
+ return __ptr_.first() != nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer release() _NOEXCEPT {
+ pointer __t = __ptr_.first();
+ __ptr_.first() = pointer();
+ return __t;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void reset(pointer __p = pointer()) _NOEXCEPT {
+ pointer __tmp = __ptr_.first();
+ __ptr_.first() = __p;
+ if (__tmp)
+ __ptr_.second()(__tmp);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unique_ptr& __u) _NOEXCEPT {
+ __ptr_.swap(__u.__ptr_);
+ }
+};
+
+
+template <class _Tp, class _Dp>
+class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {
+public:
+ typedef _Tp element_type;
+ typedef _Dp deleter_type;
+ typedef typename __pointer<_Tp, deleter_type>::type pointer;
+
+private:
+ __compressed_pair<pointer, deleter_type> __ptr_;
+
+ template <class _From>
+ struct _CheckArrayPointerConversion : is_same<_From, pointer> {};
+
+ template <class _FromElem>
+ struct _CheckArrayPointerConversion<_FromElem*>
+ : integral_constant<bool,
+ is_same<_FromElem*, pointer>::value ||
+ (is_same<pointer, element_type*>::value &&
+ is_convertible<_FromElem(*)[], element_type(*)[]>::value)
+ >
+ {};
+
+ typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
+
+ template <bool _Dummy>
+ using _LValRefType _LIBCPP_NODEBUG_TYPE =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
+
+ template <bool _Dummy>
+ using _GoodRValRefType _LIBCPP_NODEBUG_TYPE =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
+
+ template <bool _Dummy>
+ using _BadRValRefType _LIBCPP_NODEBUG_TYPE =
+ typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
+
+ template <bool _Dummy, class _Deleter = typename __dependent_type<
+ __identity<deleter_type>, _Dummy>::type>
+ using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE =
+ typename enable_if<is_default_constructible<_Deleter>::value &&
+ !is_pointer<_Deleter>::value>::type;
+
+ template <class _ArgType>
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE =
+ typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
+
+ template <class _Pp>
+ using _EnableIfPointerConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
+ _CheckArrayPointerConversion<_Pp>::value
+ >::type;
+
+ template <class _UPtr, class _Up,
+ class _ElemT = typename _UPtr::element_type>
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
+ is_array<_Up>::value &&
+ is_same<pointer, element_type*>::value &&
+ is_same<typename _UPtr::pointer, _ElemT*>::value &&
+ is_convertible<_ElemT(*)[], element_type(*)[]>::value
+ >::type;
+
+ template <class _UDel>
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
+ (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
+ (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
+ >::type;
+
+ template <class _UDel>
+ using _EnableIfDeleterAssignable _LIBCPP_NODEBUG_TYPE = typename enable_if<
+ is_assignable<_Dp&, _UDel&&>::value
+ >::type;
+
+public:
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
+
+ template <class _Pp, bool _Dummy = true,
+ class = _EnableIfDeleterDefaultConstructible<_Dummy>,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit unique_ptr(_Pp __p) _NOEXCEPT
+ : __ptr_(__p, __default_init_tag()) {}
+
+ template <class _Pp, bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(__p, __d) {}
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(nullptr, __d) {}
+
+ template <class _Pp, bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(__p, _VSTD::move(__d)) {
+ static_assert(!is_reference<deleter_type>::value,
+ "rvalue deleter bound to reference");
+ }
+
+ template <bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
+ : __ptr_(nullptr, _VSTD::move(__d)) {
+ static_assert(!is_reference<deleter_type>::value,
+ "rvalue deleter bound to reference");
+ }
+
+ template <class _Pp, bool _Dummy = true,
+ class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(unique_ptr&& __u) _NOEXCEPT
+ : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
+ reset(__u.release());
+ __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
+ return *this;
+ }
+
+ template <class _Up, class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterConvertible<_Ep>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
+ : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {
+ }
+
+ template <class _Up, class _Ep,
+ class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
+ class = _EnableIfDeleterAssignable<_Ep>
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr&
+ operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
+ reset(__u.release());
+ __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
+ return *this;
+ }
+
+#ifdef _LIBCPP_CXX03_LANG
+ unique_ptr(unique_ptr const&) = delete;
+ unique_ptr& operator=(unique_ptr const&) = delete;
+#endif
+
+public:
+ _LIBCPP_INLINE_VISIBILITY
+ ~unique_ptr() { reset(); }
+
+ _LIBCPP_INLINE_VISIBILITY
+ unique_ptr& operator=(nullptr_t) _NOEXCEPT {
+ reset();
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ typename add_lvalue_reference<_Tp>::type
+ operator[](size_t __i) const {
+ return __ptr_.first()[__i];
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ pointer get() const _NOEXCEPT {
+ return __ptr_.first();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ deleter_type& get_deleter() _NOEXCEPT {
+ return __ptr_.second();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ const deleter_type& get_deleter() const _NOEXCEPT {
+ return __ptr_.second();
+ }
+ _LIBCPP_INLINE_VISIBILITY
+ explicit operator bool() const _NOEXCEPT {
+ return __ptr_.first() != nullptr;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ pointer release() _NOEXCEPT {
+ pointer __t = __ptr_.first();
+ __ptr_.first() = pointer();
+ return __t;
+ }
+
+ template <class _Pp>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<
+ _CheckArrayPointerConversion<_Pp>::value
+ >::type
+ reset(_Pp __p) _NOEXCEPT {
+ pointer __tmp = __ptr_.first();
+ __ptr_.first() = __p;
+ if (__tmp)
+ __ptr_.second()(__tmp);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void reset(nullptr_t = nullptr) _NOEXCEPT {
+ pointer __tmp = __ptr_.first();
+ __ptr_.first() = nullptr;
+ if (__tmp)
+ __ptr_.second()(__tmp);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void swap(unique_ptr& __u) _NOEXCEPT {
+ __ptr_.swap(__u.__ptr_);
+ }
+
+};
+
+template <class _Tp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<
+ __is_swappable<_Dp>::value,
+ void
+>::type
+swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y)
+{
+ typedef typename unique_ptr<_T1, _D1>::pointer _P1;
+ typedef typename unique_ptr<_T2, _D2>::pointer _P2;
+ typedef typename common_type<_P1, _P2>::type _Vp;
+ return less<_Vp>()(__x.get(), __y.get());
+}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
+{
+ return !__x;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
+{
+ return !__x;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
+{
+ return static_cast<bool>(__x);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+ typedef typename unique_ptr<_T1, _D1>::pointer _P1;
+ return less<_P1>()(__x.get(), nullptr);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+ typedef typename unique_ptr<_T1, _D1>::pointer _P1;
+ return less<_P1>()(nullptr, __x.get());
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+ return nullptr < __x;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+ return __x < nullptr;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+ return !(nullptr < __x);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+ return !(__x < nullptr);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+ return !(__x < nullptr);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+ return !(nullptr < __x);
+}
+
+#if _LIBCPP_STD_VER > 11
+
+template<class _Tp>
+struct __unique_if
+{
+ typedef unique_ptr<_Tp> __unique_single;
+};
+
+template<class _Tp>
+struct __unique_if<_Tp[]>
+{
+ typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
+};
+
+template<class _Tp, size_t _Np>
+struct __unique_if<_Tp[_Np]>
+{
+ typedef void __unique_array_known_bound;
+};
+
+template<class _Tp, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __unique_if<_Tp>::__unique_single
+make_unique(_Args&&... __args)
+{
+ return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __unique_if<_Tp>::__unique_array_unknown_bound
+make_unique(size_t __n)
+{
+ typedef typename remove_extent<_Tp>::type _Up;
+ return unique_ptr<_Tp>(new _Up[__n]());
+}
+
+template<class _Tp, class... _Args>
+ typename __unique_if<_Tp>::__unique_array_known_bound
+ make_unique(_Args&&...) = delete;
+
+#endif // _LIBCPP_STD_VER > 11
+
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
+
+template <class _Tp, class _Dp>
+#ifdef _LIBCPP_CXX03_LANG
+struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
+#else
+struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper<
+ unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
+#endif
+{
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef unique_ptr<_Tp, _Dp> argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY
+ size_t operator()(const unique_ptr<_Tp, _Dp>& __ptr) const
+ {
+ typedef typename unique_ptr<_Tp, _Dp>::pointer pointer;
+ return hash<pointer>()(__ptr.get());
+ }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___MEMORY_UNIQUE_PTR_H
diff --git a/contrib/llvm-project/libcxx/include/__memory/uses_allocator.h b/contrib/llvm-project/libcxx/include/__memory/uses_allocator.h
new file mode 100644
index 000000000000..36e752057545
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__memory/uses_allocator.h
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MEMORY_USES_ALLOCATOR_H
+#define _LIBCPP___MEMORY_USES_ALLOCATOR_H
+
+#include <__config>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __has_allocator_type
+{
+private:
+ struct __two {char __lx; char __lxx;};
+ template <class _Up> static __two __test(...);
+ template <class _Up> static char __test(typename _Up::allocator_type* = 0);
+public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
+struct __uses_allocator
+ : public integral_constant<bool,
+ is_convertible<_Alloc, typename _Tp::allocator_type>::value>
+{
+};
+
+template <class _Tp, class _Alloc>
+struct __uses_allocator<_Tp, _Alloc, false>
+ : public false_type
+{
+};
+
+template <class _Tp, class _Alloc>
+struct _LIBCPP_TEMPLATE_VIS uses_allocator
+ : public __uses_allocator<_Tp, _Alloc>
+{
+};
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Alloc>
+_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___MEMORY_USES_ALLOCATOR_H
diff --git a/contrib/llvm-project/libcxx/include/__mutex_base b/contrib/llvm-project/libcxx/include/__mutex_base
index 96454ace9f4d..77590a8fd4f1 100644
--- a/contrib/llvm-project/libcxx/include/__mutex_base
+++ b/contrib/llvm-project/libcxx/include/__mutex_base
@@ -11,10 +11,9 @@
#define _LIBCPP___MUTEX_BASE
#include <__config>
+#include <__threading_support>
#include <chrono>
#include <system_error>
-#include <__threading_support>
-
#include <time.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -190,8 +189,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool owns_lock() const _NOEXCEPT {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT
- operator bool () const _NOEXCEPT {return __owns_;}
+ explicit operator bool() const _NOEXCEPT {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
@@ -526,4 +524,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___MUTEX_BASE
+#endif // _LIBCPP___MUTEX_BASE
diff --git a/contrib/llvm-project/libcxx/include/__node_handle b/contrib/llvm-project/libcxx/include/__node_handle
index be1fe17a8728..f3ffa5e3ac38 100644
--- a/contrib/llvm-project/libcxx/include/__node_handle
+++ b/contrib/llvm-project/libcxx/include/__node_handle
@@ -11,6 +11,7 @@
#define _LIBCPP___NODE_HANDLE
#include <__config>
+#include <__debug>
#include <memory>
#include <optional>
@@ -205,4 +206,4 @@ struct _LIBCPP_TEMPLATE_VIS __insert_return_type
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif
+#endif // _LIBCPP___NODE_HANDLE
diff --git a/contrib/llvm-project/libcxx/include/__nullptr b/contrib/llvm-project/libcxx/include/__nullptr
index 45529a710b63..e14751164237 100644
--- a/contrib/llvm-project/libcxx/include/__nullptr
+++ b/contrib/llvm-project/libcxx/include/__nullptr
@@ -56,6 +56,6 @@ namespace std
typedef decltype(nullptr) nullptr_t;
}
-#endif // _LIBCPP_HAS_NO_NULLPTR
+#endif // _LIBCPP_HAS_NO_NULLPTR
-#endif // _LIBCPP_NULLPTR
+#endif // _LIBCPP_NULLPTR
diff --git a/contrib/llvm-project/libcxx/include/__random/uniform_int_distribution.h b/contrib/llvm-project/libcxx/include/__random/uniform_int_distribution.h
new file mode 100644
index 000000000000..a7cfa1ec7305
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__random/uniform_int_distribution.h
@@ -0,0 +1,316 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
+#define _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
+
+#include <__bits>
+#include <__config>
+#include <cstddef>
+#include <cstdint>
+#include <iosfwd>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __independent_bits_engine
+
+template <unsigned long long _Xp, size_t _Rp>
+struct __log2_imp
+{
+ static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp
+ : __log2_imp<_Xp, _Rp - 1>::value;
+};
+
+template <unsigned long long _Xp>
+struct __log2_imp<_Xp, 0>
+{
+ static const size_t value = 0;
+};
+
+template <size_t _Rp>
+struct __log2_imp<0, _Rp>
+{
+ static const size_t value = _Rp + 1;
+};
+
+template <class _UIntType, _UIntType _Xp>
+struct __log2
+{
+ static const size_t value = __log2_imp<_Xp,
+ sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
+};
+
+template<class _Engine, class _UIntType>
+class __independent_bits_engine
+{
+public:
+ // types
+ typedef _UIntType result_type;
+
+private:
+ typedef typename _Engine::result_type _Engine_result_type;
+ typedef typename conditional
+ <
+ sizeof(_Engine_result_type) <= sizeof(result_type),
+ result_type,
+ _Engine_result_type
+ >::type _Working_result_type;
+
+ _Engine& __e_;
+ size_t __w_;
+ size_t __w0_;
+ size_t __n_;
+ size_t __n0_;
+ _Working_result_type __y0_;
+ _Working_result_type __y1_;
+ _Engine_result_type __mask0_;
+ _Engine_result_type __mask1_;
+
+#ifdef _LIBCPP_CXX03_LANG
+ static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
+ + _Working_result_type(1);
+#else
+ static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
+ + _Working_result_type(1);
+#endif
+ static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value;
+ static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits;
+ static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits;
+
+public:
+ // constructors and seeding functions
+ __independent_bits_engine(_Engine& __e, size_t __w);
+
+ // generating functions
+ result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
+
+private:
+ result_type __eval(false_type);
+ result_type __eval(true_type);
+};
+
+template<class _Engine, class _UIntType>
+__independent_bits_engine<_Engine, _UIntType>
+ ::__independent_bits_engine(_Engine& __e, size_t __w)
+ : __e_(__e),
+ __w_(__w)
+{
+ __n_ = __w_ / __m + (__w_ % __m != 0);
+ __w0_ = __w_ / __n_;
+ if (_Rp == 0)
+ __y0_ = _Rp;
+ else if (__w0_ < _WDt)
+ __y0_ = (_Rp >> __w0_) << __w0_;
+ else
+ __y0_ = 0;
+ if (_Rp - __y0_ > __y0_ / __n_)
+ {
+ ++__n_;
+ __w0_ = __w_ / __n_;
+ if (__w0_ < _WDt)
+ __y0_ = (_Rp >> __w0_) << __w0_;
+ else
+ __y0_ = 0;
+ }
+ __n0_ = __n_ - __w_ % __n_;
+ if (__w0_ < _WDt - 1)
+ __y1_ = (_Rp >> (__w0_ + 1)) << (__w0_ + 1);
+ else
+ __y1_ = 0;
+ __mask0_ = __w0_ > 0 ? _Engine_result_type(~0) >> (_EDt - __w0_) :
+ _Engine_result_type(0);
+ __mask1_ = __w0_ < _EDt - 1 ?
+ _Engine_result_type(~0) >> (_EDt - (__w0_ + 1)) :
+ _Engine_result_type(~0);
+}
+
+template<class _Engine, class _UIntType>
+inline
+_UIntType
+__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
+{
+ return static_cast<result_type>(__e_() & __mask0_);
+}
+
+template<class _Engine, class _UIntType>
+_UIntType
+__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
+{
+ const size_t _WRt = numeric_limits<result_type>::digits;
+ result_type _Sp = 0;
+ for (size_t __k = 0; __k < __n0_; ++__k)
+ {
+ _Engine_result_type __u;
+ do
+ {
+ __u = __e_() - _Engine::min();
+ } while (__u >= __y0_);
+ if (__w0_ < _WRt)
+ _Sp <<= __w0_;
+ else
+ _Sp = 0;
+ _Sp += __u & __mask0_;
+ }
+ for (size_t __k = __n0_; __k < __n_; ++__k)
+ {
+ _Engine_result_type __u;
+ do
+ {
+ __u = __e_() - _Engine::min();
+ } while (__u >= __y1_);
+ if (__w0_ < _WRt - 1)
+ _Sp <<= __w0_ + 1;
+ else
+ _Sp = 0;
+ _Sp += __u & __mask1_;
+ }
+ return _Sp;
+}
+
+template<class _IntType = int>
+class uniform_int_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class param_type
+ {
+ result_type __a_;
+ result_type __b_;
+ public:
+ typedef uniform_int_distribution distribution_type;
+
+ explicit param_type(result_type __a = 0,
+ result_type __b = numeric_limits<result_type>::max())
+ : __a_(__a), __b_(__b) {}
+
+ result_type a() const {return __a_;}
+ result_type b() const {return __b_;}
+
+ friend bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+ friend bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructors and reset functions
+#ifndef _LIBCPP_CXX03_LANG
+ uniform_int_distribution() : uniform_int_distribution(0) {}
+ explicit uniform_int_distribution(
+ result_type __a, result_type __b = numeric_limits<result_type>::max())
+ : __p_(param_type(__a, __b)) {}
+#else
+ explicit uniform_int_distribution(
+ result_type __a = 0,
+ result_type __b = numeric_limits<result_type>::max())
+ : __p_(param_type(__a, __b)) {}
+#endif
+ explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {}
+ void reset() {}
+
+ // generating functions
+ template<class _URNG> result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ result_type a() const {return __p_.a();}
+ result_type b() const {return __p_.b();}
+
+ param_type param() const {return __p_;}
+ void param(const param_type& __p) {__p_ = __p;}
+
+ result_type min() const {return a();}
+ result_type max() const {return b();}
+
+ friend bool operator==(const uniform_int_distribution& __x,
+ const uniform_int_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend bool operator!=(const uniform_int_distribution& __x,
+ const uniform_int_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template<class _IntType>
+template<class _URNG>
+typename uniform_int_distribution<_IntType>::result_type
+uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
+_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+{
+ typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t),
+ uint32_t, uint64_t>::type _UIntType;
+ const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
+ if (_Rp == 1)
+ return __p.a();
+ const size_t _Dt = numeric_limits<_UIntType>::digits;
+ typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
+ if (_Rp == 0)
+ return static_cast<result_type>(_Eng(__g, _Dt)());
+ size_t __w = _Dt - __libcpp_clz(_Rp) - 1;
+ if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
+ ++__w;
+ _Eng __e(__g, __w);
+ _UIntType __u;
+ do
+ {
+ __u = __e();
+ } while (__u >= _Rp);
+ return static_cast<result_type>(__u + __p.a());
+}
+
+template <class _CharT, class _Traits, class _IT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const uniform_int_distribution<_IT>& __x)
+{
+ __save_flags<_CharT, _Traits> __lx(__os);
+ typedef basic_ostream<_CharT, _Traits> _Ostream;
+ __os.flags(_Ostream::dec | _Ostream::left);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ return __os << __x.a() << __sp << __x.b();
+}
+
+template <class _CharT, class _Traits, class _IT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ uniform_int_distribution<_IT>& __x)
+{
+ typedef uniform_int_distribution<_IT> _Eng;
+ typedef typename _Eng::result_type result_type;
+ typedef typename _Eng::param_type param_type;
+ __save_flags<_CharT, _Traits> __lx(__is);
+ typedef basic_istream<_CharT, _Traits> _Istream;
+ __is.flags(_Istream::dec | _Istream::skipws);
+ result_type __a;
+ result_type __b;
+ __is >> __a >> __b;
+ if (!__is.fail())
+ __x.param(param_type(__a, __b));
+ return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/access.h b/contrib/llvm-project/libcxx/include/__ranges/access.h
new file mode 100644
index 000000000000..add848887c11
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/access.h
@@ -0,0 +1,222 @@
+// -*- C++ -*-
+//===------------------------ __ranges/access.h ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_ACCESS_H
+#define _LIBCPP___RANGES_ACCESS_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/readable_traits.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format off
+
+namespace ranges {
+ template <class _Tp>
+ concept __can_borrow =
+ is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp> >;
+
+ template<class _Tp>
+ concept __is_complete = requires { sizeof(_Tp); };
+} // namespace ranges
+
+// [range.access.begin]
+namespace ranges::__begin {
+ template <class _Tp>
+ concept __member_begin =
+ __can_borrow<_Tp> &&
+ requires(_Tp&& __t) {
+ { _VSTD::__decay_copy(__t.begin()) } -> input_or_output_iterator;
+ };
+
+ void begin(auto&) = delete;
+ void begin(const auto&) = delete;
+
+ template <class _Tp>
+ concept __unqualified_begin =
+ !__member_begin<_Tp> &&
+ __can_borrow<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp> > &&
+ requires(_Tp && __t) {
+ { _VSTD::__decay_copy(begin(__t)) } -> input_or_output_iterator;
+ };
+
+ struct __fn {
+ template <class _Tp>
+ requires is_array_v<remove_cv_t<_Tp>>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const noexcept {
+ constexpr bool __complete = __is_complete<iter_value_t<_Tp> >;
+ if constexpr (__complete) { // used to disable cryptic diagnostic
+ return __t + 0;
+ }
+ else {
+ static_assert(__complete, "`std::ranges::begin` is SFINAE-unfriendly on arrays of an incomplete type.");
+ }
+ }
+
+ template <class _Tp>
+ requires __member_begin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::__decay_copy(__t.begin())))
+ {
+ return __t.begin();
+ }
+
+ template <class _Tp>
+ requires __unqualified_begin<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::__decay_copy(begin(__t))))
+ {
+ return begin(__t);
+ }
+
+ void operator()(auto&&) const = delete;
+ };
+} // namespace ranges::__begin
+
+namespace ranges {
+ inline namespace __cpo {
+ inline constexpr auto begin = __begin::__fn{};
+ } // namespace __cpo
+
+ template <class _Tp>
+ using iterator_t = decltype(ranges::begin(declval<_Tp&>()));
+} // namespace ranges
+
+// [range.access.end]
+namespace ranges::__end {
+ template <class _Tp>
+ concept __member_end =
+ __can_borrow<_Tp> &&
+ requires(_Tp&& __t) {
+ typename iterator_t<_Tp>;
+ { _VSTD::__decay_copy(_VSTD::forward<_Tp>(__t).end()) } -> sentinel_for<iterator_t<_Tp> >;
+ };
+
+ void end(auto&) = delete;
+ void end(const auto&) = delete;
+
+ template <class _Tp>
+ concept __unqualified_end =
+ !__member_end<_Tp> &&
+ __can_borrow<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp> > &&
+ requires(_Tp && __t) {
+ typename iterator_t<_Tp>;
+ { _VSTD::__decay_copy(end(_VSTD::forward<_Tp>(__t))) } -> sentinel_for<iterator_t<_Tp> >;
+ };
+
+ class __fn {
+ public:
+ template <class _Tp, size_t _Np>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept {
+ constexpr bool __complete = __is_complete<remove_cv_t<_Tp> >;
+ if constexpr (__complete) { // used to disable cryptic diagnostic
+ return __t + _Np;
+ }
+ else {
+ static_assert(__complete, "`std::ranges::end` is SFINAE-unfriendly on arrays of an incomplete type.");
+ }
+ }
+
+ template <class _Tp>
+ requires __member_end<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::__decay_copy(__t.end())))
+ {
+ return _VSTD::forward<_Tp>(__t).end();
+ }
+
+ template <class _Tp>
+ requires __unqualified_end<_Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::__decay_copy(end(__t))))
+ {
+ return end(__t);
+ }
+
+ void operator()(auto&&) const = delete;
+ };
+} // namespace ranges::__end
+
+namespace ranges::inline __cpo {
+ inline constexpr auto end = __end::__fn{};
+} // namespace ranges::__cpo
+
+namespace ranges::__cbegin {
+ struct __fn {
+ template <class _Tp>
+ requires invocable<decltype(ranges::begin), _Tp const&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const
+ noexcept(noexcept(ranges::begin(_VSTD::as_const(__t))))
+ {
+ return ranges::begin(_VSTD::as_const(__t));
+ }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::begin), _Tp const&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::begin(static_cast<_Tp const&&>(__t))))
+ {
+ return ranges::begin(static_cast<_Tp const&&>(__t));
+ }
+ };
+} // namespace ranges::__cbegin
+
+namespace ranges::inline __cpo {
+ inline constexpr auto cbegin = __cbegin::__fn{};
+} // namespace ranges::__cpo
+
+namespace ranges::__cend {
+ struct __fn {
+ template <class _Tp>
+ requires invocable<decltype(ranges::end), _Tp const&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const
+ noexcept(noexcept(ranges::end(_VSTD::as_const(__t))))
+ {
+ return ranges::end(_VSTD::as_const(__t));
+ }
+
+ template <class _Tp>
+ requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::end), _Tp const&&>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::end(static_cast<_Tp const&&>(__t))))
+ {
+ return ranges::end(static_cast<_Tp const&&>(__t));
+ }
+ };
+} // namespace ranges::__cend
+
+namespace ranges::inline __cpo {
+ inline constexpr auto cend = __cend::__fn{};
+} // namespace ranges::__cpo
+
+// clang-format off
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_ACCESS_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/all.h b/contrib/llvm-project/libcxx/include/__ranges/all.h
new file mode 100644
index 000000000000..d678d3e5d357
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/all.h
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_ALL_H
+#define _LIBCPP___RANGES_ALL_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/ref_view.h>
+#include <__ranges/subrange.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace views {
+
+namespace __all {
+ struct __fn {
+ template<class _Tp>
+ requires ranges::view<decay_t<_Tp>>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::__decay_copy(_VSTD::forward<_Tp>(__t))))
+ {
+ return _VSTD::forward<_Tp>(__t);
+ }
+
+ template<class _Tp>
+ requires (!ranges::view<decay_t<_Tp>>) &&
+ requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::ref_view{_VSTD::forward<_Tp>(__t)}))
+ {
+ return ranges::ref_view{_VSTD::forward<_Tp>(__t)};
+ }
+
+ template<class _Tp>
+ requires (!ranges::view<decay_t<_Tp>> &&
+ !requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } &&
+ requires (_Tp&& __t) { ranges::subrange{_VSTD::forward<_Tp>(__t)}; })
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::subrange{_VSTD::forward<_Tp>(__t)}))
+ {
+ return ranges::subrange{_VSTD::forward<_Tp>(__t)};
+ }
+ };
+}
+
+inline namespace __cpo {
+ inline constexpr auto all = __all::__fn{};
+} // namespace __cpo
+
+template<ranges::viewable_range _Range>
+using all_t = decltype(views::all(declval<_Range>()));
+
+} // namespace views
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_ALL_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/common_view.h b/contrib/llvm-project/libcxx/include/__ranges/common_view.h
new file mode 100644
index 000000000000..dab82602f671
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/common_view.h
@@ -0,0 +1,113 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_COMMON_VIEW_H
+#define _LIBCPP___RANGES_COMMON_VIEW_H
+
+#include <__config>
+#include <__iterator/common_iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+
+template<view _View>
+ requires (!common_range<_View> && copyable<iterator_t<_View>>)
+class common_view : public view_interface<common_view<_View>> {
+ _View __base_ = _View();
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ common_view() requires default_initializable<_View> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit common_view(_View __v) : __base_(_VSTD::move(__v)) { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return _VSTD::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() {
+ if constexpr (random_access_range<_View> && sized_range<_View>)
+ return ranges::begin(__base_);
+ else
+ return common_iterator<iterator_t<_View>, sentinel_t<_View>>(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const requires range<const _View> {
+ if constexpr (random_access_range<const _View> && sized_range<const _View>)
+ return ranges::begin(__base_);
+ else
+ return common_iterator<iterator_t<const _View>, sentinel_t<const _View>>(ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() {
+ if constexpr (random_access_range<_View> && sized_range<_View>)
+ return ranges::begin(__base_) + ranges::size(__base_);
+ else
+ return common_iterator<iterator_t<_View>, sentinel_t<_View>>(ranges::end(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const requires range<const _View> {
+ if constexpr (random_access_range<const _View> && sized_range<const _View>)
+ return ranges::begin(__base_) + ranges::size(__base_);
+ else
+ return common_iterator<iterator_t<const _View>, sentinel_t<const _View>>(ranges::end(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() requires sized_range<_View> {
+ return ranges::size(__base_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const requires sized_range<const _View> {
+ return ranges::size(__base_);
+ }
+};
+
+template<class _Range>
+common_view(_Range&&)
+ -> common_view<views::all_t<_Range>>;
+
+template<class _View>
+inline constexpr bool enable_borrowed_range<common_view<_View>> = enable_borrowed_range<_View>;
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_COMMON_VIEW_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/concepts.h b/contrib/llvm-project/libcxx/include/__ranges/concepts.h
new file mode 100644
index 000000000000..2f912c2841e8
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/concepts.h
@@ -0,0 +1,138 @@
+// -*- C++ -*-
+//===--------------------- __ranges/concepts.h ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_CONCEPTS_H
+#define _LIBCPP___RANGES_CONCEPTS_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/readable_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/data.h>
+#include <__ranges/enable_view.h>
+#include <__ranges/size.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// clang-format off
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+ // [range.range]
+ template <class _Tp>
+ concept range = requires(_Tp& __t) {
+ ranges::begin(__t); // sometimes equality-preserving
+ ranges::end(__t);
+ };
+
+ template<class _Range>
+ concept borrowed_range = range<_Range> &&
+ (is_lvalue_reference_v<_Range> || enable_borrowed_range<remove_cvref_t<_Range>>);
+
+ // `iterator_t` defined in <__ranges/access.h>
+
+ template <range _Rp>
+ using sentinel_t = decltype(ranges::end(declval<_Rp&>()));
+
+ template <range _Rp>
+ using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
+
+ template <range _Rp>
+ using range_value_t = iter_value_t<iterator_t<_Rp>>;
+
+ template <range _Rp>
+ using range_reference_t = iter_reference_t<iterator_t<_Rp>>;
+
+ template <range _Rp>
+ using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<_Rp>>;
+
+ // [range.sized]
+ template <class _Tp>
+ concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
+
+ template<sized_range _Rp>
+ using range_size_t = decltype(ranges::size(declval<_Rp&>()));
+
+ // `disable_sized_range` defined in `<__ranges/size.h>`
+
+ // [range.view], views
+
+ // `enable_view` defined in <__ranges/enable_view.h>
+ // `view_base` defined in <__ranges/enable_view.h>
+
+ template <class _Tp>
+ concept view =
+ range<_Tp> &&
+ movable<_Tp> &&
+ enable_view<_Tp>;
+
+ template<class _Range>
+ concept __simple_view =
+ view<_Range> && range<const _Range> &&
+ same_as<iterator_t<_Range>, iterator_t<const _Range>> &&
+ same_as<sentinel_t<_Range>, iterator_t<const _Range>>;
+
+ // [range.refinements], other range refinements
+ template <class _Rp, class _Tp>
+ concept output_range = range<_Rp> && output_iterator<iterator_t<_Rp>, _Tp>;
+
+ template <class _Tp>
+ concept input_range = range<_Tp> && input_iterator<iterator_t<_Tp>>;
+
+ template <class _Tp>
+ concept forward_range = input_range<_Tp> && forward_iterator<iterator_t<_Tp>>;
+
+ template <class _Tp>
+ concept bidirectional_range = forward_range<_Tp> && bidirectional_iterator<iterator_t<_Tp>>;
+
+ template <class _Tp>
+ concept random_access_range =
+ bidirectional_range<_Tp> && random_access_iterator<iterator_t<_Tp>>;
+
+ template<class _Tp>
+ concept contiguous_range =
+ random_access_range<_Tp> &&
+ contiguous_iterator<iterator_t<_Tp>> &&
+ requires(_Tp& __t) {
+ { ranges::data(__t) } -> same_as<add_pointer_t<range_reference_t<_Tp>>>;
+ };
+
+ template <class _Tp>
+ concept common_range = range<_Tp> && same_as<iterator_t<_Tp>, sentinel_t<_Tp>>;
+
+ template<class _Tp>
+ concept viewable_range =
+ range<_Tp> && (
+ (view<remove_cvref_t<_Tp>> && constructible_from<remove_cvref_t<_Tp>, _Tp>) ||
+ (!view<remove_cvref_t<_Tp>> && borrowed_range<_Tp>)
+ );
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format on
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_CONCEPTS_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h b/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h
new file mode 100644
index 000000000000..f2d3843f79f5
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/copyable_box.h
@@ -0,0 +1,175 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_COPYABLE_BOX_H
+#define _LIBCPP___RANGES_COPYABLE_BOX_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <__memory/construct_at.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <optional>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into
+// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state
+// and basically doing destroy-then-copy-construct in the assignment operator. The empty state is necessary
+// to handle the case where the copy construction fails after destroying the object.
+//
+// In some cases, we can completely avoid the use of an empty state; we provide a specialization of
+// __copyable_box that does this, see below for the details.
+
+template<class _Tp>
+concept __copy_constructible_object = copy_constructible<_Tp> && is_object_v<_Tp>;
+
+namespace ranges {
+ // Primary template - uses std::optional and introduces an empty state in case assignment fails.
+ template<__copy_constructible_object _Tp>
+ class __copyable_box {
+ [[no_unique_address]] optional<_Tp> __val_;
+
+ public:
+ template<class ..._Args>
+ requires is_constructible_v<_Tp, _Args...>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)
+ noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
+ : __val_(in_place, _VSTD::forward<_Args>(__args)...)
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __copyable_box() noexcept(is_nothrow_default_constructible_v<_Tp>)
+ requires default_initializable<_Tp>
+ : __val_(in_place)
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI __copyable_box(__copyable_box const&) = default;
+ _LIBCPP_HIDE_FROM_ABI __copyable_box(__copyable_box&&) = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __copyable_box& operator=(__copyable_box const& __other)
+ noexcept(is_nothrow_copy_constructible_v<_Tp>)
+ {
+ if (this != _VSTD::addressof(__other)) {
+ if (__other.__has_value()) __val_.emplace(*__other);
+ else __val_.reset();
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ __copyable_box& operator=(__copyable_box&&) requires movable<_Tp> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __copyable_box& operator=(__copyable_box&& __other)
+ noexcept(is_nothrow_move_constructible_v<_Tp>)
+ {
+ if (this != _VSTD::addressof(__other)) {
+ if (__other.__has_value()) __val_.emplace(_VSTD::move(*__other));
+ else __val_.reset();
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return *__val_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return *__val_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return __val_.has_value(); }
+ };
+
+ // This partial specialization implements an optimization for when we know we don't need to store
+ // an empty state to represent failure to perform an assignment. For copy-assignment, this happens:
+ //
+ // 1. If the type is copyable (which includes copy-assignment), we can use the type's own assignment operator
+ // directly and avoid using std::optional.
+ // 2. If the type is not copyable, but it is nothrow-copy-constructible, then we can implement assignment as
+ // destroy-and-then-construct and we know it will never fail, so we don't need an empty state.
+ //
+ // The exact same reasoning can be applied for move-assignment, with copyable replaced by movable and
+ // nothrow-copy-constructible replaced by nothrow-move-constructible. This specialization is enabled
+ // whenever we can apply any of these optimizations for both the copy assignment and the move assignment
+ // operator.
+ template<class _Tp>
+ concept __doesnt_need_empty_state_for_copy = copyable<_Tp> || is_nothrow_copy_constructible_v<_Tp>;
+
+ template<class _Tp>
+ concept __doesnt_need_empty_state_for_move = movable<_Tp> || is_nothrow_move_constructible_v<_Tp>;
+
+ template<__copy_constructible_object _Tp>
+ requires __doesnt_need_empty_state_for_copy<_Tp> && __doesnt_need_empty_state_for_move<_Tp>
+ class __copyable_box<_Tp> {
+ [[no_unique_address]] _Tp __val_;
+
+ public:
+ template<class ..._Args>
+ requires is_constructible_v<_Tp, _Args...>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __copyable_box(in_place_t, _Args&& ...__args)
+ noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
+ : __val_(_VSTD::forward<_Args>(__args)...)
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __copyable_box() noexcept(is_nothrow_default_constructible_v<_Tp>)
+ requires default_initializable<_Tp>
+ : __val_()
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI __copyable_box(__copyable_box const&) = default;
+ _LIBCPP_HIDE_FROM_ABI __copyable_box(__copyable_box&&) = default;
+
+ // Implementation of assignment operators in case we perform optimization (1)
+ _LIBCPP_HIDE_FROM_ABI __copyable_box& operator=(__copyable_box const&) requires copyable<_Tp> = default;
+ _LIBCPP_HIDE_FROM_ABI __copyable_box& operator=(__copyable_box&&) requires movable<_Tp> = default;
+
+ // Implementation of assignment operators in case we perform optimization (2)
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __copyable_box& operator=(__copyable_box const& __other) noexcept {
+ static_assert(is_nothrow_copy_constructible_v<_Tp>);
+ if (this != _VSTD::addressof(__other)) {
+ _VSTD::destroy_at(_VSTD::addressof(__val_));
+ _VSTD::construct_at(_VSTD::addressof(__val_), __other.__val_);
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __copyable_box& operator=(__copyable_box&& __other) noexcept {
+ static_assert(is_nothrow_move_constructible_v<_Tp>);
+ if (this != _VSTD::addressof(__other)) {
+ _VSTD::destroy_at(_VSTD::addressof(__val_));
+ _VSTD::construct_at(_VSTD::addressof(__val_), _VSTD::move(__other.__val_));
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return __val_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return __val_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; }
+ };
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_COPYABLE_BOX_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/dangling.h b/contrib/llvm-project/libcxx/include/__ranges/dangling.h
new file mode 100644
index 000000000000..deb02a1a448d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/dangling.h
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_DANGLING_H
+#define _LIBCPP___RANGES_DANGLING_H
+
+#include <__config>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+struct dangling {
+ dangling() = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr dangling(auto&&...) noexcept {}
+};
+
+template <range _Rp>
+using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>;
+
+// borrowed_subrange_t defined in <__ranges/subrange.h>
+} // namespace ranges
+
+#endif // !_LIBCPP_HAS_NO_RANGES
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_DANGLING_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/data.h b/contrib/llvm-project/libcxx/include/__ranges/data.h
new file mode 100644
index 000000000000..dae30984d3f9
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/data.h
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//===------------------------ __ranges/data.h ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_DATA_H
+#define _LIBCPP___RANGES_DATA_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h>
+#include <__ranges/access.h>
+#include <__utility/forward.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format off
+namespace ranges {
+// [range.prim.data]
+namespace __data {
+ template <class _Tp>
+ concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>;
+
+ template <class _Tp>
+ concept __member_data =
+ requires(_Tp&& __t) {
+ { _VSTD::forward<_Tp>(__t) } -> __can_borrow;
+ { __t.data() } -> __ptr_to_object;
+ };
+
+ template <class _Tp>
+ concept __ranges_begin_invocable =
+ !__member_data<_Tp> &&
+ requires(_Tp&& __t) {
+ { _VSTD::forward<_Tp>(__t) } -> __can_borrow;
+ { ranges::begin(_VSTD::forward<_Tp>(__t)) } -> contiguous_iterator;
+ };
+
+ struct __fn {
+ template <__member_data _Tp>
+ requires __can_borrow<_Tp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __ptr_to_object auto operator()(_Tp&& __t) const
+ noexcept(noexcept(__t.data())) {
+ return __t.data();
+ }
+
+ template<__ranges_begin_invocable _Tp>
+ requires __can_borrow<_Tp>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __ptr_to_object auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::to_address(ranges::begin(_VSTD::forward<_Tp>(__t))))) {
+ return _VSTD::to_address(ranges::begin(_VSTD::forward<_Tp>(__t)));
+ }
+ };
+} // end namespace __data
+
+inline namespace __cpo {
+ inline constexpr const auto data = __data::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// clang-format off
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_DATA_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/drop_view.h b/contrib/llvm-project/libcxx/include/__ranges/drop_view.h
new file mode 100644
index 000000000000..099fd227111d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/drop_view.h
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_DROP_VIEW_H
+#define _LIBCPP___RANGES_DROP_VIEW_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__utility/move.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+ template<view _View>
+ class drop_view
+ : public view_interface<drop_view<_View>>
+ {
+ // We cache begin() whenever ranges::next is not guaranteed O(1) to provide an
+ // amortized O(1) begin() method. If this is an input_range, then we cannot cache
+ // begin because begin is not equality preserving.
+ // Note: drop_view<input-range>::begin() is still trivially amortized O(1) because
+ // one can't call begin() on it more than once.
+ static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>);
+ using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
+ [[no_unique_address]] _Cache __cached_begin_ = _Cache();
+ range_difference_t<_View> __count_ = 0;
+ _View __base_ = _View();
+
+public:
+ drop_view() requires default_initializable<_View> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr drop_view(_View __base, range_difference_t<_View> __count)
+ : __count_(__count)
+ , __base_(_VSTD::move(__base))
+ {
+ _LIBCPP_ASSERT(__count_ >= 0, "count must be greater than or equal to zero.");
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return _VSTD::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin()
+ requires (!(__simple_view<_View> &&
+ random_access_range<const _View> && sized_range<const _View>))
+ {
+ if constexpr (_UseCache)
+ if (__cached_begin_.__has_value())
+ return *__cached_begin_;
+
+ auto __tmp = ranges::next(ranges::begin(__base_), __count_, ranges::end(__base_));
+ if constexpr (_UseCache)
+ __cached_begin_.__set(__tmp);
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto begin() const
+ requires random_access_range<const _View> && sized_range<const _View>
+ {
+ return ranges::next(ranges::begin(__base_), __count_, ranges::end(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end()
+ requires (!__simple_view<_View>)
+ { return ranges::end(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto end() const
+ requires range<const _View>
+ { return ranges::end(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ static constexpr auto __size(auto& __self) {
+ const auto __s = ranges::size(__self.__base_);
+ const auto __c = static_cast<decltype(__s)>(__self.__count_);
+ return __s < __c ? 0 : __s - __c;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size()
+ requires sized_range<_View>
+ { return __size(*this); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const
+ requires sized_range<const _View>
+ { return __size(*this); }
+ };
+
+ template<class _Range>
+ drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>;
+
+ template<class _Tp>
+ inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>;
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_DROP_VIEW_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/empty.h b/contrib/llvm-project/libcxx/include/__ranges/empty.h
new file mode 100644
index 000000000000..73892a8c1035
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/empty.h
@@ -0,0 +1,86 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_EMPTY_H
+#define _LIBCPP___RANGES_EMPTY_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__ranges/access.h>
+#include <__ranges/size.h>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format off
+namespace ranges {
+// [range.prim.empty]
+namespace __empty {
+ template <class _Tp>
+ concept __member_empty = requires(_Tp&& __t) {
+ bool(_VSTD::forward<_Tp>(__t).empty());
+ };
+
+ template<class _Tp>
+ concept __can_invoke_size =
+ !__member_empty<_Tp> &&
+ requires(_Tp&& __t) { ranges::size(_VSTD::forward<_Tp>(__t)); };
+
+ template <class _Tp>
+ concept __can_compare_begin_end =
+ !__member_empty<_Tp> &&
+ !__can_invoke_size<_Tp> &&
+ requires(_Tp&& __t) {
+ bool(ranges::begin(__t) == ranges::end(__t));
+ { ranges::begin(__t) } -> forward_iterator;
+ };
+
+ struct __fn {
+ template <__member_empty _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t) const
+ noexcept(noexcept(bool(__t.empty()))) {
+ return __t.empty();
+ }
+
+ template <__can_invoke_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::size(_VSTD::forward<_Tp>(__t)))) {
+ return ranges::size(_VSTD::forward<_Tp>(__t)) == 0;
+ }
+
+ template<__can_compare_begin_end _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t) const
+ noexcept(noexcept(bool(ranges::begin(__t) == ranges::end(__t)))) {
+ return ranges::begin(__t) == ranges::end(__t);
+ }
+ };
+}
+
+inline namespace __cpo {
+ inline constexpr auto empty = __empty::__fn{};
+} // namespace __cpo
+} // namespace ranges
+// clang-format off
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_EMPTY_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/empty_view.h b/contrib/llvm-project/libcxx/include/__ranges/empty_view.h
new file mode 100644
index 000000000000..7c0f307c8243
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/empty_view.h
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_EMPTY_VIEW_H
+#define _LIBCPP___RANGES_EMPTY_VIEW_H
+
+#include <__config>
+#include <__ranges/view_interface.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+ template<class _Tp>
+ requires is_object_v<_Tp>
+ class empty_view : public view_interface<empty_view<_Tp>> {
+ public:
+ _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* begin() noexcept { return nullptr; }
+ _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* end() noexcept { return nullptr; }
+ _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* data() noexcept { return nullptr; }
+ _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; }
+ _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; }
+ };
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_EMPTY_VIEW_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h b/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h
new file mode 100644
index 000000000000..618b2223c716
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/enable_borrowed_range.h
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===------------------ __ranges/enable_borrowed_range.h ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H
+#define _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H
+
+// These customization variables are used in <span> and <string_view>. The
+// separate header is used to avoid including the entire <ranges> header in
+// <span> and <string_view>.
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges
+{
+
+// [range.range], ranges
+
+template <class>
+inline constexpr bool enable_borrowed_range = false;
+
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/enable_view.h b/contrib/llvm-project/libcxx/include/__ranges/enable_view.h
new file mode 100644
index 000000000000..2628d51ced49
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/enable_view.h
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RANGES_ENABLE_VIEW_H
+#define _LIBCPP___RANGES_ENABLE_VIEW_H
+
+#include <__config>
+#include <concepts>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+
+struct view_base { };
+
+template <class _Tp>
+inline constexpr bool enable_view = derived_from<_Tp, view_base>;
+
+} // end namespace ranges
+
+#endif // !_LIBCPP_HAS_NO_RANGES
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_ENABLE_VIEW_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h b/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h
new file mode 100644
index 000000000000..878f7070a07f
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/non_propagating_cache.h
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
+#define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
+
+#include <__config>
+#include <__iterator/concepts.h> // indirectly_readable
+#include <__iterator/iterator_traits.h> // iter_reference_t
+#include <__memory/addressof.h>
+#include <concepts> // constructible_from
+#include <optional>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// clang-format off
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+ // __non_propagating_cache is a helper type that allows storing an optional value in it,
+ // but which does not copy the source's value when it is copy constructed/assigned to,
+ // and which resets the source's value when it is moved-from.
+ //
+ // This type is used as an implementation detail of some views that need to cache the
+ // result of `begin()` in order to provide an amortized O(1) begin() method. Typically,
+ // we don't want to propagate the value of the cache upon copy because the cached iterator
+ // may refer to internal details of the source view.
+ template<class _Tp>
+ requires is_object_v<_Tp>
+ class _LIBCPP_TEMPLATE_VIS __non_propagating_cache {
+ optional<_Tp> __value_ = nullopt;
+
+ public:
+ _LIBCPP_HIDE_FROM_ABI __non_propagating_cache() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __non_propagating_cache(__non_propagating_cache const&) noexcept
+ : __value_(nullopt)
+ { }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __non_propagating_cache(__non_propagating_cache&& __other) noexcept
+ : __value_(nullopt)
+ {
+ __other.__value_.reset();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __non_propagating_cache& operator=(__non_propagating_cache const& __other) noexcept {
+ if (this != _VSTD::addressof(__other)) {
+ __value_.reset();
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __non_propagating_cache& operator=(__non_propagating_cache&& __other) noexcept {
+ __value_.reset();
+ __other.__value_.reset();
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp& operator*() { return *__value_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Tp const& operator*() const { return *__value_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool __has_value() const { return __value_.has_value(); }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void __set(_Tp const& __value) { __value_.emplace(__value); }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void __set(_Tp&& __value) { __value_.emplace(_VSTD::move(__value)); }
+ };
+
+ struct __empty_cache { };
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/ref_view.h b/contrib/llvm-project/libcxx/include/__ranges/ref_view.h
new file mode 100644
index 000000000000..fb45a359863b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/ref_view.h
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_REF_VIEW_H
+#define _LIBCPP___RANGES_REF_VIEW_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/data.h>
+#include <__ranges/empty.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+ template<range _Range>
+ requires is_object_v<_Range>
+ class ref_view : public view_interface<ref_view<_Range>> {
+ _Range *__range_;
+
+ static void __fun(_Range&);
+ static void __fun(_Range&&) = delete;
+
+public:
+ template<class _Tp>
+ requires __different_from<_Tp, ref_view> &&
+ convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr ref_view(_Tp&& __t)
+ : __range_(_VSTD::addressof(static_cast<_Range&>(_VSTD::forward<_Tp>(__t))))
+ {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Range> begin() const { return ranges::begin(*__range_); }
+ _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Range> end() const { return ranges::end(*__range_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr bool empty() const
+ requires requires { ranges::empty(*__range_); }
+ { return ranges::empty(*__range_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const
+ requires sized_range<_Range>
+ { return ranges::size(*__range_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto data() const
+ requires contiguous_range<_Range>
+ { return ranges::data(*__range_); }
+ };
+
+ template<class _Range>
+ ref_view(_Range&) -> ref_view<_Range>;
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_REF_VIEW_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/size.h b/contrib/llvm-project/libcxx/include/__ranges/size.h
new file mode 100644
index 000000000000..ce7183e15447
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/size.h
@@ -0,0 +1,132 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_SIZE_H
+#define _LIBCPP___RANGES_SIZE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format off
+namespace ranges {
+template<class>
+inline constexpr bool disable_sized_range = false;
+
+// [range.prim.size]
+namespace __size {
+ void size(auto&) = delete;
+ void size(const auto&) = delete;
+
+ template <class _Tp>
+ concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
+
+ template <class _Tp>
+ concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) {
+ { _VSTD::__decay_copy(_VSTD::forward<_Tp>(__t).size()) } -> __integer_like;
+ };
+
+ template <class _Tp>
+ concept __unqualified_size =
+ __size_enabled<_Tp> &&
+ !__member_size<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ { _VSTD::__decay_copy(size(_VSTD::forward<_Tp>(__t))) } -> __integer_like;
+ };
+
+ template <class _Tp>
+ concept __difference =
+ !__member_size<_Tp> &&
+ !__unqualified_size<_Tp> &&
+ __class_or_enum<remove_cvref_t<_Tp>> &&
+ requires(_Tp&& __t) {
+ { ranges::begin(__t) } -> forward_iterator;
+ { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
+ };
+
+ struct __fn {
+ template <class _Tp, size_t _Sz>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept {
+ return _Sz;
+ }
+
+ template <class _Tp, size_t _Sz>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept {
+ return _Sz;
+ }
+
+ template <__member_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
+ noexcept(noexcept(_VSTD::forward<_Tp>(__t).size())) {
+ return _VSTD::forward<_Tp>(__t).size();
+ }
+
+ template <__unqualified_size _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
+ noexcept(noexcept(size(_VSTD::forward<_Tp>(__t)))) {
+ return size(_VSTD::forward<_Tp>(__t));
+ }
+
+ template<__difference _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::end(__t) - ranges::begin(__t))) {
+ return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t));
+ }
+ };
+} // end namespace __size
+
+inline namespace __cpo {
+ inline constexpr auto size = __size::__fn{};
+} // namespace __cpo
+
+namespace __ssize {
+ struct __fn {
+ template<class _Tp>
+ requires requires (_Tp&& __t) { ranges::size(__t); }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const
+ noexcept(noexcept(ranges::size(__t))) {
+ using _Signed = make_signed_t<decltype(ranges::size(__t))>;
+ if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))
+ return static_cast<ptrdiff_t>(ranges::size(__t));
+ else
+ return static_cast<_Signed>(ranges::size(__t));
+ }
+ };
+}
+
+inline namespace __cpo {
+ inline constexpr const auto ssize = __ssize::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+// clang-format off
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_SIZE_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/subrange.h b/contrib/llvm-project/libcxx/include/__ranges/subrange.h
new file mode 100644
index 000000000000..25d333db02de
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/subrange.h
@@ -0,0 +1,267 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_SUBRANGE_H
+#define _LIBCPP___RANGES_SUBRANGE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/advance.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+// clang-format off
+namespace ranges {
+ template<class _From, class _To>
+ concept __convertible_to_non_slicing =
+ convertible_to<_From, _To> &&
+ // If they're both pointers, they must have the same element type.
+ !(is_pointer_v<decay_t<_From>> &&
+ is_pointer_v<decay_t<_To>> &&
+ __different_from<remove_pointer_t<decay_t<_From>>, remove_pointer_t<decay_t<_To>>>);
+
+ template<class _Tp>
+ concept __pair_like =
+ !is_reference_v<_Tp> && requires(_Tp __t) {
+ typename tuple_size<_Tp>::type; // Ensures `tuple_size<T>` is complete.
+ requires derived_from<tuple_size<_Tp>, integral_constant<size_t, 2>>;
+ typename tuple_element_t<0, remove_const_t<_Tp>>;
+ typename tuple_element_t<1, remove_const_t<_Tp>>;
+ { _VSTD::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;
+ { _VSTD::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;
+ };
+
+ template<class _Pair, class _Iter, class _Sent>
+ concept __pair_like_convertible_from =
+ !range<_Pair> && __pair_like<_Pair> &&
+ constructible_from<_Pair, _Iter, _Sent> &&
+ __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> &&
+ convertible_to<_Sent, tuple_element_t<1, _Pair>>;
+
+ enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized };
+
+ template<class _Iter, class _Sent, bool>
+ struct __subrange_base {
+ static constexpr bool __store_size = false;
+ _Iter __begin_ = _Iter();
+ _Sent __end_ = _Sent();
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __subrange_base() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __subrange_base(_Iter __iter, _Sent __sent, make_unsigned_t<iter_difference_t<_Iter>> = 0)
+ : __begin_(_VSTD::move(__iter)), __end_(__sent) { }
+ };
+
+ template<class _Iter, class _Sent>
+ struct __subrange_base<_Iter, _Sent, true> {
+ static constexpr bool __store_size = true;
+ _Iter __begin_ = _Iter();
+ _Sent __end_ = _Sent();
+ make_unsigned_t<iter_difference_t<_Iter>> __size_ = 0;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __subrange_base() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __subrange_base(_Iter __iter, _Sent __sent, decltype(__size_) __size)
+ : __begin_(_VSTD::move(__iter)), __end_(__sent), __size_(__size) { }
+ };
+
+ template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent = _Iter,
+ subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter>
+ ? subrange_kind::sized
+ : subrange_kind::unsized>
+ requires (_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
+ struct _LIBCPP_TEMPLATE_VIS subrange
+ : public view_interface<subrange<_Iter, _Sent, _Kind>>,
+ private __subrange_base<_Iter, _Sent, _Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>> {
+
+ using _Base = __subrange_base<_Iter, _Sent, _Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ subrange() requires default_initializable<_Iter> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent)
+ requires (!_Base::__store_size)
+ : _Base(_VSTD::move(__iter), __sent) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent,
+ make_unsigned_t<iter_difference_t<_Iter>> __n)
+ requires (_Kind == subrange_kind::sized)
+ : _Base(_VSTD::move(__iter), __sent, __n) { }
+
+ template<__different_from<subrange> _Range>
+ requires borrowed_range<_Range> &&
+ __convertible_to_non_slicing<iterator_t<_Range>, _Iter> &&
+ convertible_to<sentinel_t<_Range>, _Sent>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr subrange(_Range&& __range)
+ requires (!_Base::__store_size)
+ : subrange(ranges::begin(__range), ranges::end(__range)) { }
+
+ template<__different_from<subrange> _Range>
+ requires borrowed_range<_Range> &&
+ __convertible_to_non_slicing<iterator_t<_Range>, _Iter> &&
+ convertible_to<sentinel_t<_Range>, _Sent>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr subrange(_Range&& __range)
+ requires _Base::__store_size && sized_range<_Range>
+ : subrange(__range, ranges::size(__range)) { }
+
+
+ template<borrowed_range _Range>
+ requires __convertible_to_non_slicing<iterator_t<_Range>, _Iter> &&
+ convertible_to<sentinel_t<_Range>, _Sent>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr subrange(_Range&& __range, make_unsigned_t<iter_difference_t<_Iter>> __n)
+ requires (_Kind == subrange_kind::sized)
+ : subrange(ranges::begin(__range), ranges::end(__range), __n) { }
+
+ template<__different_from<subrange> _Pair>
+ requires __pair_like_convertible_from<_Pair, const _Iter&, const _Sent&>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr operator _Pair() const { return _Pair(this->__begin_, this->__end_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Iter begin() const requires copyable<_Iter> {
+ return this->__begin_;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) {
+ return _VSTD::move(this->__begin_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Sent end() const { return this->__end_; }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return this->__begin_ == this->__end_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr make_unsigned_t<iter_difference_t<_Iter>> size() const
+ requires (_Kind == subrange_kind::sized)
+ {
+ if constexpr (_Base::__store_size)
+ return this->__size_;
+ else
+ return __to_unsigned_like(this->__end_ - this->__begin_);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) const&
+ requires forward_iterator<_Iter> {
+ auto __tmp = *this;
+ __tmp.advance(__n);
+ return __tmp;
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) && {
+ advance(__n);
+ return _VSTD::move(*this);
+ }
+
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange prev(iter_difference_t<_Iter> __n = 1) const
+ requires bidirectional_iterator<_Iter> {
+ auto __tmp = *this;
+ __tmp.advance(-__n);
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr subrange& advance(iter_difference_t<_Iter> __n) {
+ if constexpr (bidirectional_iterator<_Iter>) {
+ if (__n < 0) {
+ ranges::advance(this->__begin_, __n);
+ if constexpr (_Base::__store_size)
+ this->__size_ += _VSTD::__to_unsigned_like(-__n);
+ return *this;
+ }
+ }
+
+ auto __d = __n - ranges::advance(this->__begin_, __n, this->__end_);
+ if constexpr (_Base::__store_size)
+ this->__size_ -= _VSTD::__to_unsigned_like(__d);
+ return *this;
+ }
+ };
+
+ template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
+ subrange(_Iter, _Sent) -> subrange<_Iter, _Sent>;
+
+ template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
+ subrange(_Iter, _Sent, make_unsigned_t<iter_difference_t<_Iter>>)
+ -> subrange<_Iter, _Sent, subrange_kind::sized>;
+
+ template<borrowed_range _Range>
+ subrange(_Range&&) -> subrange<iterator_t<_Range>, sentinel_t<_Range>,
+ (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>)
+ ? subrange_kind::sized : subrange_kind::unsized>;
+
+ template<borrowed_range _Range>
+ subrange(_Range&&, make_unsigned_t<range_difference_t<_Range>>)
+ -> subrange<iterator_t<_Range>, sentinel_t<_Range>, subrange_kind::sized>;
+
+ template<size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
+ requires (_Index < 2)
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange) {
+ if constexpr (_Index == 0)
+ return __subrange.begin();
+ else
+ return __subrange.end();
+ }
+
+ template<size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
+ requires (_Index < 2)
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange) {
+ if constexpr (_Index == 0)
+ return __subrange.begin();
+ else
+ return __subrange.end();
+ }
+
+ template<class _Ip, class _Sp, subrange_kind _Kp>
+ inline constexpr bool enable_borrowed_range<subrange<_Ip, _Sp, _Kp>> = true;
+
+ template<range _Rp>
+ using borrowed_subrange_t = _If<borrowed_range<_Rp>, subrange<iterator_t<_Rp> >, dangling>;
+} // namespace ranges
+
+using ranges::get;
+
+// clang-format off
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_SUBRANGE_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/transform_view.h b/contrib/llvm-project/libcxx/include/__ranges/transform_view.h
new file mode 100644
index 000000000000..4243dc0366e9
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/transform_view.h
@@ -0,0 +1,408 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H
+#define _LIBCPP___RANGES_TRANSFORM_VIEW_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/copyable_box.h>
+#include <__ranges/empty.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+
+template<class _View, class _Fn>
+concept __transform_view_constraints =
+ view<_View> && is_object_v<_Fn> &&
+ regular_invocable<_Fn&, range_reference_t<_View>> &&
+ __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>;
+
+template<input_range _View, copy_constructible _Fn>
+ requires __transform_view_constraints<_View, _Fn>
+class transform_view : public view_interface<transform_view<_View, _Fn>> {
+ template<bool> class __iterator;
+ template<bool> class __sentinel;
+
+ [[no_unique_address]] __copyable_box<_Fn> __func_;
+ [[no_unique_address]] _View __base_ = _View();
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ transform_view()
+ requires default_initializable<_View> && default_initializable<_Fn> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr transform_view(_View __base, _Fn __func)
+ : __func_(_VSTD::in_place, _VSTD::move(__func)), __base_(_VSTD::move(__base)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _View base() && { return _VSTD::move(__base_); }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator<false> begin() {
+ return __iterator<false>{*this, ranges::begin(__base_)};
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator<true> begin() const
+ requires range<const _View> &&
+ regular_invocable<const _Fn&, range_reference_t<const _View>>
+ {
+ return __iterator<true>(*this, ranges::begin(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel<false> end() {
+ return __sentinel<false>(ranges::end(__base_));
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator<false> end()
+ requires common_range<_View>
+ {
+ return __iterator<false>(*this, ranges::end(__base_));
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel<true> end() const
+ requires range<const _View> &&
+ regular_invocable<const _Fn&, range_reference_t<const _View>>
+ {
+ return __sentinel<true>(ranges::end(__base_));
+ }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator<true> end() const
+ requires common_range<const _View> &&
+ regular_invocable<const _Fn&, range_reference_t<const _View>>
+ {
+ return __iterator<true>(*this, ranges::end(__base_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() requires sized_range<_View> { return ranges::size(__base_); }
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const requires sized_range<const _View> { return ranges::size(__base_); }
+};
+
+template<class _Range, class _Fn>
+transform_view(_Range&&, _Fn) -> transform_view<views::all_t<_Range>, _Fn>;
+
+template<class _View>
+struct __transform_view_iterator_concept { using type = input_iterator_tag; };
+
+template<random_access_range _View>
+struct __transform_view_iterator_concept<_View> { using type = random_access_iterator_tag; };
+
+template<bidirectional_range _View>
+struct __transform_view_iterator_concept<_View> { using type = bidirectional_iterator_tag; };
+
+template<forward_range _View>
+struct __transform_view_iterator_concept<_View> { using type = forward_iterator_tag; };
+
+template<class, class>
+struct __transform_view_iterator_category_base {};
+
+template<forward_range _View, class _Fn>
+struct __transform_view_iterator_category_base<_View, _Fn> {
+ using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category;
+
+ using iterator_category = conditional_t<
+ is_lvalue_reference_v<invoke_result_t<_Fn&, range_reference_t<_View>>>,
+ conditional_t<
+ derived_from<_Cat, contiguous_iterator_tag>,
+ random_access_iterator_tag,
+ _Cat
+ >,
+ input_iterator_tag
+ >;
+};
+
+template<input_range _View, copy_constructible _Fn>
+ requires __transform_view_constraints<_View, _Fn>
+template<bool _Const>
+class transform_view<_View, _Fn>::__iterator
+ : public __transform_view_iterator_category_base<_View, _Fn> {
+
+ using _Parent = __maybe_const<_Const, transform_view>;
+ using _Base = __maybe_const<_Const, _View>;
+
+ _Parent *__parent_ = nullptr;
+
+ template<bool>
+ friend class transform_view<_View, _Fn>::__iterator;
+
+ template<bool>
+ friend class transform_view<_View, _Fn>::__sentinel;
+
+public:
+ iterator_t<_Base> __current_ = iterator_t<_Base>();
+
+ using iterator_concept = typename __transform_view_iterator_concept<_View>::type;
+ using value_type = remove_cvref_t<invoke_result_t<_Fn&, range_reference_t<_Base>>>;
+ using difference_type = range_difference_t<_Base>;
+
+ _LIBCPP_HIDE_FROM_ABI
+ __iterator() requires default_initializable<iterator_t<_Base>> = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)
+ : __parent_(_VSTD::addressof(__parent)), __current_(_VSTD::move(__current)) {}
+
+ // Note: `__i` should always be `__iterator<false>`, but directly using
+ // `__iterator<false>` is ill-formed when `_Const` is false
+ // (see http://wg21.link/class.copy.ctor#5).
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator(__iterator<!_Const> __i)
+ requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
+ : __parent_(__i.__parent_), __current_(_VSTD::move(__i.__current_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_Base> base() const&
+ requires copyable<iterator_t<_Base>>
+ {
+ return __current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr iterator_t<_Base> base() && {
+ return _VSTD::move(__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator*() const
+ noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, *__current_)))
+ {
+ return _VSTD::invoke(*__parent_->__func_, *__current_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator++() {
+ ++__current_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void operator++(int) { ++__current_; }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator++(int)
+ requires forward_range<_Base>
+ {
+ auto __tmp = *this;
+ ++*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator--()
+ requires bidirectional_range<_Base>
+ {
+ --__current_;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator operator--(int)
+ requires bidirectional_range<_Base>
+ {
+ auto __tmp = *this;
+ --*this;
+ return __tmp;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator+=(difference_type __n)
+ requires random_access_range<_Base>
+ {
+ __current_ += __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __iterator& operator-=(difference_type __n)
+ requires random_access_range<_Base>
+ {
+ __current_ -= __n;
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator[](difference_type __n) const
+ noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, __current_[__n])))
+ requires random_access_range<_Base>
+ {
+ return _VSTD::invoke(*__parent_->__func_, __current_[__n]);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
+ requires equality_comparable<iterator_t<_Base>>
+ {
+ return __x.__current_ == __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __x.__current_ < __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __x.__current_ > __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __x.__current_ <= __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
+ requires random_access_range<_Base>
+ {
+ return __x.__current_ >= __y.__current_;
+ }
+
+// TODO: Fix this as soon as soon as three_way_comparable is implemented.
+// _LIBCPP_HIDE_FROM_ABI
+// friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
+// requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
+// {
+// return __x.__current_ <=> __y.__current_;
+// }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator+(__iterator __i, difference_type __n)
+ requires random_access_range<_Base>
+ {
+ return __iterator{*__i.__parent_, __i.__current_ + __n};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator+(difference_type __n, __iterator __i)
+ requires random_access_range<_Base>
+ {
+ return __iterator{*__i.__parent_, __i.__current_ + __n};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr __iterator operator-(__iterator __i, difference_type __n)
+ requires random_access_range<_Base>
+ {
+ return __iterator{*__i.__parent_, __i.__current_ - __n};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
+ requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
+ {
+ return __x.__current_ - __y.__current_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr decltype(auto) iter_move(const __iterator& __i)
+ noexcept(noexcept(*__i))
+ {
+ if constexpr (is_lvalue_reference_v<decltype(*__i)>)
+ return _VSTD::move(*__i);
+ else
+ return *__i;
+ }
+};
+
+template<input_range _View, copy_constructible _Fn>
+ requires __transform_view_constraints<_View, _Fn>
+template<bool _Const>
+class transform_view<_View, _Fn>::__sentinel {
+ using _Parent = __maybe_const<_Const, transform_view>;
+ using _Base = __maybe_const<_Const, _View>;
+
+ sentinel_t<_Base> __end_ = sentinel_t<_Base>();
+
+ template<bool>
+ friend class transform_view<_View, _Fn>::__iterator;
+
+ template<bool>
+ friend class transform_view<_View, _Fn>::__sentinel;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ __sentinel() = default;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(__end) {}
+
+ // Note: `__i` should always be `__sentinel<false>`, but directly using
+ // `__sentinel<false>` is ill-formed when `_Const` is false
+ // (see http://wg21.link/class.copy.ctor#5).
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr __sentinel(__sentinel<!_Const> __i)
+ requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+ : __end_(_VSTD::move(__i.__end_)) {}
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr sentinel_t<_Base> base() const { return __end_; }
+
+ template<bool _OtherConst>
+ requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
+ return __x.__current_ == __y.__end_;
+ }
+
+ template<bool _OtherConst>
+ requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
+ operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
+ return __x.__current_ - __y.__end_;
+ }
+
+ template<bool _OtherConst>
+ requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
+ _LIBCPP_HIDE_FROM_ABI
+ friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
+ operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
+ return __x.__end_ - __y.__current_;
+ }
+};
+
+} // namespace ranges
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_TRANSFORM_VIEW_H
diff --git a/contrib/llvm-project/libcxx/include/__ranges/view_interface.h b/contrib/llvm-project/libcxx/include/__ranges/view_interface.h
new file mode 100644
index 000000000000..62cc5fd24362
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__ranges/view_interface.h
@@ -0,0 +1,198 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
+#define _LIBCPP___RANGES_VIEW_INTERFACE_H
+
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/prev.h>
+#include <__memory/pointer_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/empty.h>
+#include <__ranges/enable_view.h>
+#include <concepts>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+
+namespace ranges {
+
+template<class _Tp>
+concept __can_empty = requires(_Tp __t) { ranges::empty(__t); };
+
+template<class _Tp>
+void __implicitly_convert_to(type_identity_t<_Tp>) noexcept;
+
+template<class _Derived>
+ requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>
+class view_interface : public view_base {
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Derived& __derived() noexcept {
+ return static_cast<_Derived&>(*this);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr _Derived const& __derived() const noexcept {
+ return static_cast<_Derived const&>(*this);
+ }
+
+public:
+ template<class _D2 = _Derived>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
+ noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived()))))
+ requires forward_range<_D2>
+ {
+ return ranges::begin(__derived()) == ranges::end(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
+ noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived()))))
+ requires forward_range<const _D2>
+ {
+ return ranges::begin(__derived()) == ranges::end(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool()
+ noexcept(noexcept(ranges::empty(declval<_D2>())))
+ requires __can_empty<_D2>
+ {
+ return !ranges::empty(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit operator bool() const
+ noexcept(noexcept(ranges::empty(declval<const _D2>())))
+ requires __can_empty<const _D2>
+ {
+ return !ranges::empty(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto data()
+ noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived()))))
+ requires contiguous_iterator<iterator_t<_D2>>
+ {
+ return _VSTD::to_address(ranges::begin(__derived()));
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto data() const
+ noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived()))))
+ requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>>
+ {
+ return _VSTD::to_address(ranges::begin(__derived()));
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size()
+ noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived())))
+ requires forward_range<_D2>
+ && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
+ {
+ return ranges::end(__derived()) - ranges::begin(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr auto size() const
+ noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived())))
+ requires forward_range<const _D2>
+ && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
+ {
+ return ranges::end(__derived()) - ranges::begin(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) front()
+ noexcept(noexcept(*ranges::begin(__derived())))
+ requires forward_range<_D2>
+ {
+ _LIBCPP_ASSERT(!empty(),
+ "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
+ return *ranges::begin(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) front() const
+ noexcept(noexcept(*ranges::begin(__derived())))
+ requires forward_range<const _D2>
+ {
+ _LIBCPP_ASSERT(!empty(),
+ "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
+ return *ranges::begin(__derived());
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) back()
+ noexcept(noexcept(*ranges::prev(ranges::end(__derived()))))
+ requires bidirectional_range<_D2> && common_range<_D2>
+ {
+ _LIBCPP_ASSERT(!empty(),
+ "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
+ return *ranges::prev(ranges::end(__derived()));
+ }
+
+ template<class _D2 = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) back() const
+ noexcept(noexcept(*ranges::prev(ranges::end(__derived()))))
+ requires bidirectional_range<const _D2> && common_range<const _D2>
+ {
+ _LIBCPP_ASSERT(!empty(),
+ "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
+ return *ranges::prev(ranges::end(__derived()));
+ }
+
+ template<random_access_range _RARange = _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator[](range_difference_t<_RARange> __index)
+ noexcept(noexcept(ranges::begin(__derived())[__index]))
+ {
+ return ranges::begin(__derived())[__index];
+ }
+
+ template<random_access_range _RARange = const _Derived>
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const
+ noexcept(noexcept(ranges::begin(__derived())[__index]))
+ {
+ return ranges::begin(__derived())[__index];
+ }
+};
+
+}
+
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___RANGES_VIEW_INTERFACE_H
diff --git a/contrib/llvm-project/libcxx/include/__split_buffer b/contrib/llvm-project/libcxx/include/__split_buffer
index 20480d19d31b..901c0374aa1c 100644
--- a/contrib/llvm-project/libcxx/include/__split_buffer
+++ b/contrib/llvm-project/libcxx/include/__split_buffer
@@ -3,8 +3,9 @@
#define _LIBCPP_SPLIT_BUFFER
#include <__config>
-#include <type_traits>
+#include <__utility/forward.h>
#include <algorithm>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -20,8 +21,8 @@ template <bool>
class __split_buffer_common
{
protected:
- void __throw_length_error() const;
- void __throw_out_of_range() const;
+ _LIBCPP_NORETURN void __throw_length_error() const;
+ _LIBCPP_NORETURN void __throw_out_of_range() const;
};
template <class _Tp, class _Allocator = allocator<_Tp> >
@@ -444,7 +445,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
@@ -458,7 +459,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
catch (...)
{
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -625,4 +626,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_SPLIT_BUFFER
+#endif // _LIBCPP_SPLIT_BUFFER
diff --git a/contrib/llvm-project/libcxx/include/__sso_allocator b/contrib/llvm-project/libcxx/include/__sso_allocator
deleted file mode 100644
index c50ae24c9212..000000000000
--- a/contrib/llvm-project/libcxx/include/__sso_allocator
+++ /dev/null
@@ -1,77 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___SSO_ALLOCATOR
-#define _LIBCPP___SSO_ALLOCATOR
-
-#include <__config>
-#include <memory>
-#include <new>
-#include <type_traits>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp, size_t _Np> class _LIBCPP_HIDDEN __sso_allocator;
-
-template <size_t _Np>
-class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
-{
-public:
- typedef const void* const_pointer;
- typedef void value_type;
-};
-
-template <class _Tp, size_t _Np>
-class _LIBCPP_HIDDEN __sso_allocator
-{
- typename aligned_storage<sizeof(_Tp) * _Np>::type buf_;
- bool __allocated_;
-public:
- typedef size_t size_type;
- typedef _Tp* pointer;
- typedef _Tp value_type;
-
- _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
- _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
- template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
- : __allocated_(false) {}
-private:
- __sso_allocator& operator=(const __sso_allocator&);
-public:
- _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr)
- {
- if (!__allocated_ && __n <= _Np)
- {
- __allocated_ = true;
- return (pointer)&buf_;
- }
- return allocator<_Tp>().allocate(__n);
- }
- _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n)
- {
- if (__p == (pointer)&buf_)
- __allocated_ = false;
- else
- allocator<_Tp>().deallocate(__p, __n);
- }
- _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
-
- _LIBCPP_INLINE_VISIBILITY
- bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;}
- _LIBCPP_INLINE_VISIBILITY
- bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;}
-};
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___SSO_ALLOCATOR
diff --git a/contrib/llvm-project/libcxx/include/__std_stream b/contrib/llvm-project/libcxx/include/__std_stream
index 5a9a470a9787..65e90b7894b6 100644
--- a/contrib/llvm-project/libcxx/include/__std_stream
+++ b/contrib/llvm-project/libcxx/include/__std_stream
@@ -11,10 +11,10 @@
#define _LIBCPP___STD_STREAM
#include <__config>
-#include <ostream>
-#include <istream>
#include <__locale>
#include <cstdio>
+#include <istream>
+#include <ostream>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -358,4 +358,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___STD_STREAM
+#endif // _LIBCPP___STD_STREAM
diff --git a/contrib/llvm-project/libcxx/include/__string b/contrib/llvm-project/libcxx/include/__string
index d8b672e4c1be..b77a7fb4f8d3 100644
--- a/contrib/llvm-project/libcxx/include/__string
+++ b/contrib/llvm-project/libcxx/include/__string
@@ -10,55 +10,21 @@
#ifndef _LIBCPP___STRING
#define _LIBCPP___STRING
-/*
- string synopsis
-
-namespace std
-{
-
-template <class charT>
-struct char_traits
-{
- typedef charT char_type;
- typedef ... int_type;
- typedef streamoff off_type;
- typedef streampos pos_type;
- typedef mbstate_t state_type;
-
- static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
- static constexpr bool eq(char_type c1, char_type c2) noexcept;
- static constexpr bool lt(char_type c1, char_type c2) noexcept;
-
- static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
- static constexpr size_t length(const char_type* s);
- static constexpr const char_type*
- find(const char_type* s, size_t n, const char_type& a);
-
- static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n); // constexpr in C++20
- static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n); // constexpr in C++20
- static constexpr char_type* assign(char_type* s, size_t n, char_type a); // constexpr in C++20
-
- static constexpr int_type not_eof(int_type c) noexcept;
- static constexpr char_type to_char_type(int_type c) noexcept;
- static constexpr int_type to_int_type(char_type c) noexcept;
- static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
- static constexpr int_type eof() noexcept;
-};
-
-template <> struct char_traits<char>;
-template <> struct char_traits<wchar_t>;
-template <> struct char_traits<char8_t>; // c++20
-
-} // std
-
-*/
-
#include <__config>
-#include <algorithm> // for search and min
-#include <cstdio> // for EOF
-#include <cstring> // for memcpy
-#include <cwchar> // for wmemcpy
-#include <memory> // for __murmur2_or_cityhash
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/find_first_of.h>
+#include <__algorithm/find_end.h>
+#include <__algorithm/min.h>
+#include <__functional/hash.h> // for __murmur2_or_cityhash
+#include <__iterator/iterator_traits.h>
+#include <cstdio> // for EOF
+#include <cstdint> // for uint_least16_t
+#include <cstring> // for memcpy
+#include <cwchar> // for wmemcpy
+#include <type_traits> // for __libcpp_is_constant_evaluated
#include <__debug>
@@ -581,7 +547,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
}
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
@@ -688,7 +654,7 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
return nullptr;
}
-#endif // #_LIBCPP_NO_HAS_CHAR8_T
+#endif // #_LIBCPP_HAS_NO_CHAR8_T
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
@@ -932,7 +898,7 @@ char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCE
return __r;
}
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
// helper fns for basic_string and string_view
@@ -953,7 +919,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
template <class _CharT, class _Traits>
inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
__search_substring(const _CharT *__first1, const _CharT *__last1,
- const _CharT *__first2, const _CharT *__last2) {
+ const _CharT *__first2, const _CharT *__last2) _NOEXCEPT {
// Take advantage of knowing source and pattern lengths.
// Stop short when source is smaller than pattern.
const ptrdiff_t __len2 = __last2 - __first2;
@@ -1177,4 +1143,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___STRING
+#endif // _LIBCPP___STRING
diff --git a/contrib/llvm-project/libcxx/include/__threading_support b/contrib/llvm-project/libcxx/include/__threading_support
index de572f3ff84d..4d867167c2b1 100644
--- a/contrib/llvm-project/libcxx/include/__threading_support
+++ b/contrib/llvm-project/libcxx/include/__threading_support
@@ -10,11 +10,12 @@
#ifndef _LIBCPP_THREADING_SUPPORT
#define _LIBCPP_THREADING_SUPPORT
-#include <__config>
#include <__availability>
+#include <__config>
#include <chrono>
-#include <iosfwd>
#include <errno.h>
+#include <iosfwd>
+#include <limits>
#ifdef __MVS__
# include <__support/ibm/nanosleep.h>
@@ -28,14 +29,15 @@
# include <__external_threading>
#elif !defined(_LIBCPP_HAS_NO_THREADS)
+#if defined(__APPLE__) || defined(__MVS__)
+# define _LIBCPP_NO_NATIVE_SEMAPHORES
+#endif
+
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# include <pthread.h>
# include <sched.h>
-# if defined(__APPLE__) || defined(__MVS__)
-# define _LIBCPP_NO_NATIVE_SEMAPHORES
-# endif
# ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
-# include <semaphore.h>
+# include <semaphore.h>
# endif
#elif defined(_LIBCPP_HAS_THREAD_API_C11)
# include <threads.h>
@@ -149,6 +151,9 @@ typedef void* __libcpp_condvar_t;
// Semaphore
typedef void* __libcpp_semaphore_t;
+#if defined(_LIBCPP_HAS_THREAD_API_WIN32)
+# define _LIBCPP_SEMAPHORE_MAX (::std::numeric_limits<long>::max())
+#endif
// Execute Once
typedef void* __libcpp_exec_once_flag;
@@ -390,7 +395,7 @@ bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
return pthread_mutex_trylock(__m) == 0;
}
-int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
{
return pthread_mutex_unlock(__m);
}
@@ -500,7 +505,7 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
// Thread
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
- return *__t == __libcpp_thread_t();
+ return __libcpp_thread_get_id(__t) == 0;
}
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
@@ -578,7 +583,7 @@ bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
return mtx_trylock(__m) == thrd_success;
}
-int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
{
return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
}
diff --git a/contrib/llvm-project/libcxx/include/__tree b/contrib/llvm-project/libcxx/include/__tree
index 0f6e4ec37921..6113322ed99d 100644
--- a/contrib/llvm-project/libcxx/include/__tree
+++ b/contrib/llvm-project/libcxx/include/__tree
@@ -11,10 +11,12 @@
#define _LIBCPP___TREE
#include <__config>
+#include <__utility/forward.h>
+#include <algorithm>
#include <iterator>
+#include <limits>
#include <memory>
#include <stdexcept>
-#include <algorithm>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -714,7 +716,7 @@ public:
};
template <class _VoidPtr>
-class __tree_node_base
+class _LIBCPP_STANDALONE_DEBUG __tree_node_base
: public __tree_node_base_types<_VoidPtr>::__end_node_type
{
typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes;
@@ -742,7 +744,7 @@ private:
};
template <class _Tp, class _VoidPtr>
-class __tree_node
+class _LIBCPP_STANDALONE_DEBUG __tree_node
: public __tree_node_base<_VoidPtr>
{
public:
@@ -2410,7 +2412,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(_Tree& __source)
}
}
-#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER > 14
template <class _Tp, class _Compare, class _Allocator>
typename __tree<_Tp, _Compare, _Allocator>::iterator
@@ -2743,4 +2745,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP___TREE
+#endif // _LIBCPP___TREE
diff --git a/contrib/llvm-project/libcxx/include/__tuple b/contrib/llvm-project/libcxx/include/__tuple
index 4da9ec55f354..082ec869eec7 100644
--- a/contrib/llvm-project/libcxx/include/__tuple
+++ b/contrib/llvm-project/libcxx/include/__tuple
@@ -134,7 +134,7 @@ template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<t
} // namespace detail
-#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
#if __has_builtin(__make_integer_seq)
template <size_t _Ep, size_t _Sp>
@@ -548,4 +548,4 @@ struct __sfinae_assign_base<false, true> {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP___TUPLE
+#endif // _LIBCPP___TUPLE
diff --git a/contrib/llvm-project/libcxx/include/__utility/__decay_copy.h b/contrib/llvm-project/libcxx/include/__utility/__decay_copy.h
new file mode 100644
index 000000000000..eda8db6a60f5
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/__decay_copy.h
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TYPE_TRAITS_DECAY_COPY_H
+#define _LIBCPP___TYPE_TRAITS_DECAY_COPY_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(_Tp&& __t)
+#if _LIBCPP_STD_VER > 17
+ noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp> >)
+#endif
+{
+ return _VSTD::forward<_Tp>(__t);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___TYPE_TRAITS_DECAY_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/as_const.h b/contrib/llvm-project/libcxx/include/__utility/as_const.h
new file mode 100644
index 000000000000..2f23eb431efa
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/as_const.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_AS_CONST_H
+#define _LIBCPP___UTILITY_AS_CONST_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
+
+template <class _Tp>
+void as_const(const _Tp&&) = delete;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_AS_CONST_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/cmp.h b/contrib/llvm-project/libcxx/include/__utility/cmp.h
new file mode 100644
index 000000000000..a14e373c3f4b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/cmp.h
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_CMP_H
+#define _LIBCPP___UTILITY_CMP_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <limits>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+template<class _Tp, class... _Up>
+struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {};
+
+template<class _Tp>
+concept __is_safe_integral_cmp = is_integral_v<_Tp> &&
+ !_IsSameAsAny<_Tp, bool, char,
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
+ char8_t,
+#endif
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+ char16_t, char32_t,
+#endif
+ wchar_t>::value;
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool cmp_equal(_Tp __t, _Up __u) noexcept
+{
+ if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
+ return __t == __u;
+ else if constexpr (is_signed_v<_Tp>)
+ return __t < 0 ? false : make_unsigned_t<_Tp>(__t) == __u;
+ else
+ return __u < 0 ? false : __t == make_unsigned_t<_Up>(__u);
+}
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool cmp_not_equal(_Tp __t, _Up __u) noexcept
+{
+ return !_VSTD::cmp_equal(__t, __u);
+}
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool cmp_less(_Tp __t, _Up __u) noexcept
+{
+ if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
+ return __t < __u;
+ else if constexpr (is_signed_v<_Tp>)
+ return __t < 0 ? true : make_unsigned_t<_Tp>(__t) < __u;
+ else
+ return __u < 0 ? false : __t < make_unsigned_t<_Up>(__u);
+}
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool cmp_greater(_Tp __t, _Up __u) noexcept
+{
+ return _VSTD::cmp_less(__u, __t);
+}
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool cmp_less_equal(_Tp __t, _Up __u) noexcept
+{
+ return !_VSTD::cmp_greater(__t, __u);
+}
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool cmp_greater_equal(_Tp __t, _Up __u) noexcept
+{
+ return !_VSTD::cmp_less(__t, __u);
+}
+
+template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up>
+_LIBCPP_INLINE_VISIBILITY constexpr
+bool in_range(_Up __u) noexcept
+{
+ return _VSTD::cmp_less_equal(__u, numeric_limits<_Tp>::max()) &&
+ _VSTD::cmp_greater_equal(__u, numeric_limits<_Tp>::min());
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_CMP_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/declval.h b/contrib/llvm-project/libcxx/include/__utility/declval.h
new file mode 100644
index 000000000000..185527cc6cb5
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/declval.h
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_DECLVAL_H
+#define _LIBCPP___UTILITY_DECLVAL_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Suppress deprecation notice for volatile-qualified return type resulting
+// from volatile-qualified types _Tp.
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp>
+_Tp&& __declval(int);
+template <class _Tp>
+_Tp __declval(long);
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+template <class _Tp>
+decltype(__declval<_Tp>(0)) declval() _NOEXCEPT;
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_DECLVAL_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/exchange.h b/contrib/llvm-project/libcxx/include/__utility/exchange.h
new file mode 100644
index 000000000000..4d5211d94ad1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/exchange.h
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_EXCHANGE_H
+#define _LIBCPP___UTILITY_EXCHANGE_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 11
+template<class _T1, class _T2 = _T1>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_T1 exchange(_T1& __obj, _T2 && __new_value)
+{
+ _T1 __old_value = _VSTD::move(__obj);
+ __obj = _VSTD::forward<_T2>(__new_value);
+ return __old_value;
+}
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_EXCHANGE_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/forward.h b/contrib/llvm-project/libcxx/include/__utility/forward.h
new file mode 100644
index 000000000000..c994f129007b
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/forward.h
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_FORWARD_H
+#define _LIBCPP___UTILITY_FORWARD_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&
+forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT {
+ return static_cast<_Tp&&>(__t);
+}
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&
+forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT {
+ static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");
+ return static_cast<_Tp&&>(__t);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_FORWARD_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/in_place.h b/contrib/llvm-project/libcxx/include/__utility/in_place.h
new file mode 100644
index 000000000000..964d08332747
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/in_place.h
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_IN_PLACE_H
+#define _LIBCPP___UTILITY_IN_PLACE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+struct _LIBCPP_TYPE_VIS in_place_t {
+ explicit in_place_t() = default;
+};
+_LIBCPP_INLINE_VAR constexpr in_place_t in_place{};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS in_place_type_t {
+ explicit in_place_type_t() = default;
+};
+template <class _Tp>
+_LIBCPP_INLINE_VAR constexpr in_place_type_t<_Tp> in_place_type{};
+
+template <size_t _Idx>
+struct _LIBCPP_TEMPLATE_VIS in_place_index_t {
+ explicit in_place_index_t() = default;
+};
+template <size_t _Idx>
+_LIBCPP_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{};
+
+template <class _Tp> struct __is_inplace_type_imp : false_type {};
+template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
+
+template <class _Tp>
+using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>;
+
+template <class _Tp> struct __is_inplace_index_imp : false_type {};
+template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
+
+template <class _Tp>
+using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>;
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_IN_PLACE_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/integer_sequence.h b/contrib/llvm-project/libcxx/include/__utility/integer_sequence.h
new file mode 100644
index 000000000000..963c4a967070
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/integer_sequence.h
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
+#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 11
+
+template<class _Tp, _Tp... _Ip>
+struct _LIBCPP_TEMPLATE_VIS integer_sequence
+{
+ typedef _Tp value_type;
+ static_assert( is_integral<_Tp>::value,
+ "std::integer_sequence can only be instantiated with an integral type" );
+ static
+ _LIBCPP_INLINE_VISIBILITY
+ constexpr
+ size_t
+ size() noexcept { return sizeof...(_Ip); }
+};
+
+template<size_t... _Ip>
+ using index_sequence = integer_sequence<size_t, _Ip...>;
+
+#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
+
+template <class _Tp, _Tp _Ep>
+using __make_integer_sequence _LIBCPP_NODEBUG_TYPE = __make_integer_seq<integer_sequence, _Tp, _Ep>;
+
+#else
+
+template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked _LIBCPP_NODEBUG_TYPE =
+ typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>;
+
+template <class _Tp, _Tp _Ep>
+struct __make_integer_sequence_checked
+{
+ static_assert(is_integral<_Tp>::value,
+ "std::make_integer_sequence can only be instantiated with an integral type" );
+ static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length");
+ // Workaround GCC bug by preventing bad installations when 0 <= _Ep
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
+ typedef _LIBCPP_NODEBUG_TYPE __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
+};
+
+template <class _Tp, _Tp _Ep>
+using __make_integer_sequence _LIBCPP_NODEBUG_TYPE = typename __make_integer_sequence_checked<_Tp, _Ep>::type;
+
+#endif
+
+template<class _Tp, _Tp _Np>
+ using make_integer_sequence = __make_integer_sequence<_Tp, _Np>;
+
+template<size_t _Np>
+ using make_index_sequence = make_integer_sequence<size_t, _Np>;
+
+template<class... _Tp>
+ using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
+
+#endif // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/move.h b/contrib/llvm-project/libcxx/include/__utility/move.h
new file mode 100644
index 000000000000..d3c56f93ef91
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/move.h
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_MOVE_H
+#define _LIBCPP___UTILITY_MOVE_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename remove_reference<_Tp>::type&&
+move(_Tp&& __t) _NOEXCEPT {
+ typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
+ return static_cast<_Up&&>(__t);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+using __move_if_noexcept_result_t =
+ typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
+ _Tp&&>::type;
+#else // _LIBCPP_CXX03_LANG
+template <class _Tp>
+using __move_if_noexcept_result_t = const _Tp&;
+#endif
+
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>
+move_if_noexcept(_Tp& __x) _NOEXCEPT {
+ return _VSTD::move(__x);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_MOVE_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/pair.h b/contrib/llvm-project/libcxx/include/__utility/pair.h
new file mode 100644
index 000000000000..e0216f3402b8
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/pair.h
@@ -0,0 +1,585 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_PAIR_H
+#define _LIBCPP___UTILITY_PAIR_H
+
+#include <__config>
+#include <__functional/unwrap_ref.h>
+#include <__tuple>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/piecewise_construct.h>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+template <class, class>
+struct __non_trivially_copyable_base {
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ __non_trivially_copyable_base() _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
+};
+#endif
+
+template <class _T1, class _T2>
+struct _LIBCPP_TEMPLATE_VIS pair
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+: private __non_trivially_copyable_base<_T1, _T2>
+#endif
+{
+ typedef _T1 first_type;
+ typedef _T2 second_type;
+
+ _T1 first;
+ _T2 second;
+
+#if !defined(_LIBCPP_CXX03_LANG)
+ pair(pair const&) = default;
+ pair(pair&&) = default;
+#else
+ // Use the implicitly declared copy constructor in C++03
+#endif
+
+#ifdef _LIBCPP_CXX03_LANG
+ _LIBCPP_INLINE_VISIBILITY
+ pair() : first(), second() {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {}
+
+ template <class _U1, class _U2>
+ _LIBCPP_INLINE_VISIBILITY
+ pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ pair& operator=(pair const& __p) {
+ first = __p.first;
+ second = __p.second;
+ return *this;
+ }
+#else
+ template <bool _Val>
+ using _EnableB _LIBCPP_NODEBUG_TYPE = typename enable_if<_Val, bool>::type;
+
+ struct _CheckArgs {
+ template <int&...>
+ static constexpr bool __enable_explicit_default() {
+ return is_default_constructible<_T1>::value
+ && is_default_constructible<_T2>::value
+ && !__enable_implicit_default<>();
+ }
+
+ template <int&...>
+ static constexpr bool __enable_implicit_default() {
+ return __is_implicitly_default_constructible<_T1>::value
+ && __is_implicitly_default_constructible<_T2>::value;
+ }
+
+ template <class _U1, class _U2>
+ static constexpr bool __enable_explicit() {
+ return is_constructible<first_type, _U1>::value
+ && is_constructible<second_type, _U2>::value
+ && (!is_convertible<_U1, first_type>::value
+ || !is_convertible<_U2, second_type>::value);
+ }
+
+ template <class _U1, class _U2>
+ static constexpr bool __enable_implicit() {
+ return is_constructible<first_type, _U1>::value
+ && is_constructible<second_type, _U2>::value
+ && is_convertible<_U1, first_type>::value
+ && is_convertible<_U2, second_type>::value;
+ }
+ };
+
+ template <bool _MaybeEnable>
+ using _CheckArgsDep _LIBCPP_NODEBUG_TYPE = typename conditional<
+ _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
+
+ struct _CheckTupleLikeConstructor {
+ template <class _Tuple>
+ static constexpr bool __enable_implicit() {
+ return __tuple_convertible<_Tuple, pair>::value;
+ }
+
+ template <class _Tuple>
+ static constexpr bool __enable_explicit() {
+ return __tuple_constructible<_Tuple, pair>::value
+ && !__tuple_convertible<_Tuple, pair>::value;
+ }
+
+ template <class _Tuple>
+ static constexpr bool __enable_assign() {
+ return __tuple_assignable<_Tuple, pair>::value;
+ }
+ };
+
+ template <class _Tuple>
+ using _CheckTLC _LIBCPP_NODEBUG_TYPE = typename conditional<
+ __tuple_like_with_size<_Tuple, 2>::value
+ && !is_same<typename decay<_Tuple>::type, pair>::value,
+ _CheckTupleLikeConstructor,
+ __check_tuple_constructor_fail
+ >::type;
+
+ template<bool _Dummy = true, _EnableB<
+ _CheckArgsDep<_Dummy>::__enable_explicit_default()
+ > = false>
+ explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+ is_nothrow_default_constructible<second_type>::value)
+ : first(), second() {}
+
+ template<bool _Dummy = true, _EnableB<
+ _CheckArgsDep<_Dummy>::__enable_implicit_default()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+ is_nothrow_default_constructible<second_type>::value)
+ : first(), second() {}
+
+ template <bool _Dummy = true, _EnableB<
+ _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit pair(_T1 const& __t1, _T2 const& __t2)
+ _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
+ is_nothrow_copy_constructible<second_type>::value)
+ : first(__t1), second(__t2) {}
+
+ template<bool _Dummy = true, _EnableB<
+ _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ pair(_T1 const& __t1, _T2 const& __t2)
+ _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
+ is_nothrow_copy_constructible<second_type>::value)
+ : first(__t1), second(__t2) {}
+
+ template<class _U1, class _U2, _EnableB<
+ _CheckArgs::template __enable_explicit<_U1, _U2>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit pair(_U1&& __u1, _U2&& __u2)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
+ is_nothrow_constructible<second_type, _U2>::value))
+ : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
+
+ template<class _U1, class _U2, _EnableB<
+ _CheckArgs::template __enable_implicit<_U1, _U2>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ pair(_U1&& __u1, _U2&& __u2)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
+ is_nothrow_constructible<second_type, _U2>::value))
+ : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
+
+ template<class _U1, class _U2, _EnableB<
+ _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit pair(pair<_U1, _U2> const& __p)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
+ is_nothrow_constructible<second_type, _U2 const&>::value))
+ : first(__p.first), second(__p.second) {}
+
+ template<class _U1, class _U2, _EnableB<
+ _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ pair(pair<_U1, _U2> const& __p)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
+ is_nothrow_constructible<second_type, _U2 const&>::value))
+ : first(__p.first), second(__p.second) {}
+
+ template<class _U1, class _U2, _EnableB<
+ _CheckArgs::template __enable_explicit<_U1, _U2>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit pair(pair<_U1, _U2>&&__p)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
+ is_nothrow_constructible<second_type, _U2&&>::value))
+ : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
+
+ template<class _U1, class _U2, _EnableB<
+ _CheckArgs::template __enable_implicit<_U1, _U2>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ pair(pair<_U1, _U2>&& __p)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
+ is_nothrow_constructible<second_type, _U2&&>::value))
+ : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
+
+ template<class _Tuple, _EnableB<
+ _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit pair(_Tuple&& __p)
+ : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
+ second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
+
+ template<class _Tuple, _EnableB<
+ _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ pair(_Tuple&& __p)
+ : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
+ second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
+
+ template <class... _Args1, class... _Args2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair(piecewise_construct_t __pc,
+ tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
+ _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
+ is_nothrow_constructible<second_type, _Args2...>::value))
+ : pair(__pc, __first_args, __second_args,
+ typename __make_tuple_indices<sizeof...(_Args1)>::type(),
+ typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair& operator=(typename conditional<
+ is_copy_assignable<first_type>::value &&
+ is_copy_assignable<second_type>::value,
+ pair, __nat>::type const& __p)
+ _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
+ is_nothrow_copy_assignable<second_type>::value)
+ {
+ first = __p.first;
+ second = __p.second;
+ return *this;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair& operator=(typename conditional<
+ is_move_assignable<first_type>::value &&
+ is_move_assignable<second_type>::value,
+ pair, __nat>::type&& __p)
+ _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
+ is_nothrow_move_assignable<second_type>::value)
+ {
+ first = _VSTD::forward<first_type>(__p.first);
+ second = _VSTD::forward<second_type>(__p.second);
+ return *this;
+ }
+
+ template <class _Tuple, _EnableB<
+ _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
+ > = false>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair& operator=(_Tuple&& __p) {
+ first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
+ second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
+ return *this;
+ }
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ void
+ swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
+ __is_nothrow_swappable<second_type>::value)
+ {
+ using _VSTD::swap;
+ swap(first, __p.first);
+ swap(second, __p.second);
+ }
+private:
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ pair(piecewise_construct_t,
+ tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
+ __tuple_indices<_I1...>, __tuple_indices<_I2...>);
+#endif
+};
+
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _T1, class _T2>
+pair(_T1, _T2) -> pair<_T1, _T2>;
+#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ return __x.first == __y.first && __x.second == __y.second;
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ return !(__x == __y);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ return __y < __x;
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ return !(__x < __y);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+ return !(__y < __x);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+typename enable_if
+<
+ __is_swappable<_T1>::value &&
+ __is_swappable<_T2>::value,
+ void
+>::type
+swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
+ _NOEXCEPT_((__is_nothrow_swappable<_T1>::value &&
+ __is_nothrow_swappable<_T2>::value))
+{
+ __x.swap(__y);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
+make_pair(_T1&& __t1, _T2&& __t2)
+{
+ return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
+ (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
+}
+
+#else // _LIBCPP_CXX03_LANG
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_T1,_T2>
+make_pair(_T1 __x, _T2 __y)
+{
+ return pair<_T1, _T2>(__x, __y);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+template <class _T1, class _T2>
+ struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
+ : public integral_constant<size_t, 2> {};
+
+template <size_t _Ip, class _T1, class _T2>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> >
+{
+ static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
+};
+
+template <class _T1, class _T2>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
+{
+ typedef _LIBCPP_NODEBUG_TYPE _T1 type;
+};
+
+template <class _T1, class _T2>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> >
+{
+ typedef _LIBCPP_NODEBUG_TYPE _T2 type;
+};
+
+template <size_t _Ip> struct __get_pair;
+
+template <>
+struct __get_pair<0>
+{
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _T1&
+ get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
+
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const _T1&
+ get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _T1&&
+ get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
+
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const _T1&&
+ get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}
+#endif // _LIBCPP_CXX03_LANG
+};
+
+template <>
+struct __get_pair<1>
+{
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _T2&
+ get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
+
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const _T2&
+ get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
+
+#ifndef _LIBCPP_CXX03_LANG
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ _T2&&
+ get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
+
+ template <class _T1, class _T2>
+ static
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ const _T2&&
+ get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);}
+#endif // _LIBCPP_CXX03_LANG
+};
+
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(pair<_T1, _T2>& __p) _NOEXCEPT
+{
+ return __get_pair<_Ip>::get(__p);
+}
+
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(const pair<_T1, _T2>& __p) _NOEXCEPT
+{
+ return __get_pair<_Ip>::get(__p);
+}
+
+#ifndef _LIBCPP_CXX03_LANG
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(pair<_T1, _T2>&& __p) _NOEXCEPT
+{
+ return __get_pair<_Ip>::get(_VSTD::move(__p));
+}
+
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(const pair<_T1, _T2>&& __p) _NOEXCEPT
+{
+ return __get_pair<_Ip>::get(_VSTD::move(__p));
+}
+#endif // _LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 11
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(_VSTD::move(__p));
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(_VSTD::move(__p));
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(_VSTD::move(__p));
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(_VSTD::move(__p));
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_PAIR_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/piecewise_construct.h b/contrib/llvm-project/libcxx/include/__utility/piecewise_construct.h
new file mode 100644
index 000000000000..8bef01c9f269
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/piecewise_construct.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_PIECEWISE_CONSTRUCT_H
+#define _LIBCPP___UTILITY_PIECEWISE_CONSTRUCT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { explicit piecewise_construct_t() = default; };
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
+extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
+#else
+/* _LIBCPP_INLINE_VAR */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_PIECEWISE_CONSTRUCT_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/rel_ops.h b/contrib/llvm-project/libcxx/include/__utility/rel_ops.h
new file mode 100644
index 000000000000..b900da80f48d
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/rel_ops.h
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_REL_OPS_H
+#define _LIBCPP___UTILITY_REL_OPS_H
+
+#include <__config>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace rel_ops
+{
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const _Tp& __x, const _Tp& __y)
+{
+ return !(__x == __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const _Tp& __x, const _Tp& __y)
+{
+ return __y < __x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const _Tp& __x, const _Tp& __y)
+{
+ return !(__y < __x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const _Tp& __x, const _Tp& __y)
+{
+ return !(__x < __y);
+}
+
+} // rel_ops
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_REL_OPS_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/swap.h b/contrib/llvm-project/libcxx/include/__utility/swap.h
new file mode 100644
index 000000000000..8af83a9a0f45
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/swap.h
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_SWAP_H
+#define _LIBCPP___UTILITY_SWAP_H
+
+#include <__config>
+#include <__utility/declval.h>
+#include <__utility/move.h>
+#include <type_traits>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
+#else
+template <class>
+using __swap_result_t = void;
+#endif
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CXX17 swap(_Tp& __x, _Tp& __y)
+ _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value) {
+ _Tp __t(_VSTD::move(__x));
+ __x = _VSTD::move(__y);
+ __y = _VSTD::move(__t);
+}
+
+template <class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if<__is_swappable<_Tp>::value>::type
+swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
+ for (size_t __i = 0; __i != _Np; ++__i) {
+ swap(__a[__i], __b[__i]);
+ }
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_SWAP_H
diff --git a/contrib/llvm-project/libcxx/include/__utility/to_underlying.h b/contrib/llvm-project/libcxx/include/__utility/to_underlying.h
new file mode 100644
index 000000000000..fd22f89ff595
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__utility/to_underlying.h
@@ -0,0 +1,45 @@
+// -*- C++ -*-
+//===----------------- __utility/to_underlying.h --------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___UTILITY_TO_UNDERLYING_H
+#define _LIBCPP___UTILITY_TO_UNDERLYING_H
+
+#include <__config>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr typename underlying_type<_Tp>::type
+__to_underlying(_Tp __val) noexcept {
+ return static_cast<typename underlying_type<_Tp>::type>(__val);
+}
+#endif // !_LIBCPP_CXX03_LANG
+
+#if _LIBCPP_STD_VER > 20
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY constexpr underlying_type_t<_Tp>
+to_underlying(_Tp __val) noexcept {
+ return _VSTD::__to_underlying(__val);
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___UTILITY_TO_UNDERLYING_H
diff --git a/contrib/llvm-project/libcxx/include/__variant/monostate.h b/contrib/llvm-project/libcxx/include/__variant/monostate.h
new file mode 100644
index 000000000000..36e3eead1a47
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__variant/monostate.h
@@ -0,0 +1,65 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___VARIANT_MONOSTATE_H
+#define _LIBCPP___VARIANT_MONOSTATE_H
+
+#include <__config>
+#include <__functional/hash.h>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 14
+
+struct _LIBCPP_TEMPLATE_VIS monostate {};
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<(monostate, monostate) noexcept { return false; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>(monostate, monostate) noexcept { return false; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator<=(monostate, monostate) noexcept { return true; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator>=(monostate, monostate) noexcept { return true; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator==(monostate, monostate) noexcept { return true; }
+
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr bool operator!=(monostate, monostate) noexcept { return false; }
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS hash<monostate> {
+ using argument_type = monostate;
+ using result_type = size_t;
+
+ inline _LIBCPP_INLINE_VISIBILITY
+ result_type operator()(const argument_type&) const _NOEXCEPT {
+ return 66740831; // return a fundamentally attractive random value.
+ }
+};
+
+#endif // _LIBCPP_STD_VER > 14
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___VARIANT_MONOSTATE_H
diff --git a/contrib/llvm-project/libcxx/include/algorithm b/contrib/llvm-project/libcxx/include/algorithm
index f7fb2013a757..849302a7d5da 100644
--- a/contrib/llvm-project/libcxx/include/algorithm
+++ b/contrib/llvm-project/libcxx/include/algorithm
@@ -351,11 +351,11 @@ template <class ForwardIterator, class Compare>
is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
sort(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
@@ -367,29 +367,29 @@ template <class RandomAccessIterator, class Compare>
stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
template <class InputIterator, class RandomAccessIterator>
- RandomAccessIterator
+ constexpr RandomAccessIterator // constexpr in C++20
partial_sort_copy(InputIterator first, InputIterator last,
RandomAccessIterator result_first, RandomAccessIterator result_last);
template <class InputIterator, class RandomAccessIterator, class Compare>
- RandomAccessIterator
+ constexpr RandomAccessIterator // constexpr in C++20
partial_sort_copy(InputIterator first, InputIterator last,
RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
template <class ForwardIterator, class T>
@@ -491,35 +491,35 @@ template <class InputIterator1, class InputIterator2, class OutputIterator, clas
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
push_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
pop_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
make_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
- void
+ constexpr void // constexpr in C++20
sort_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
- void
+ constexpr void // constexpr in C++20
sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
@@ -646,18 +646,113 @@ template <class BidirectionalIterator, class Compare>
*/
#include <__config>
-#include <initializer_list>
-#include <type_traits>
+#include <__debug>
+#include <__bits> // __libcpp_clz
+#include <cstddef>
#include <cstring>
+#include <functional>
+#include <initializer_list>
#include <utility> // needed to provide swap_ranges.
#include <memory>
-#include <functional>
#include <iterator>
-#include <cstddef>
-#include <bit>
+#include <memory>
+#include <type_traits>
+#include <utility> // swap_ranges
#include <version>
-#include <__debug>
+#include <__algorithm/adjacent_find.h>
+#include <__algorithm/all_of.h>
+#include <__algorithm/any_of.h>
+#include <__algorithm/binary_search.h>
+#include <__algorithm/clamp.h>
+#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/copy_if.h>
+#include <__algorithm/copy_n.h>
+#include <__algorithm/count.h>
+#include <__algorithm/count_if.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/equal_range.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/fill.h>
+#include <__algorithm/find.h>
+#include <__algorithm/find_end.h>
+#include <__algorithm/find_first_of.h>
+#include <__algorithm/find_if.h>
+#include <__algorithm/find_if_not.h>
+#include <__algorithm/for_each.h>
+#include <__algorithm/for_each_n.h>
+#include <__algorithm/generate_n.h>
+#include <__algorithm/generate.h>
+#include <__algorithm/half_positive.h>
+#include <__algorithm/includes.h>
+#include <__algorithm/inplace_merge.h>
+#include <__algorithm/is_heap.h>
+#include <__algorithm/is_heap_until.h>
+#include <__algorithm/is_partitioned.h>
+#include <__algorithm/is_permutation.h>
+#include <__algorithm/is_sorted.h>
+#include <__algorithm/is_sorted_until.h>
+#include <__algorithm/iter_swap.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/lower_bound.h>
+#include <__algorithm/make_heap.h>
+#include <__algorithm/max.h>
+#include <__algorithm/max_element.h>
+#include <__algorithm/merge.h>
+#include <__algorithm/min.h>
+#include <__algorithm/min_element.h>
+#include <__algorithm/minmax.h>
+#include <__algorithm/minmax_element.h>
+#include <__algorithm/mismatch.h>
+#include <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
+#include <__algorithm/next_permutation.h>
+#include <__algorithm/none_of.h>
+#include <__algorithm/nth_element.h>
+#include <__algorithm/partial_sort.h>
+#include <__algorithm/partial_sort_copy.h>
+#include <__algorithm/partition.h>
+#include <__algorithm/partition_copy.h>
+#include <__algorithm/partition_point.h>
+#include <__algorithm/pop_heap.h>
+#include <__algorithm/prev_permutation.h>
+#include <__algorithm/push_heap.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_copy.h>
+#include <__algorithm/remove_copy_if.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/replace.h>
+#include <__algorithm/replace_copy.h>
+#include <__algorithm/replace_copy_if.h>
+#include <__algorithm/replace_if.h>
+#include <__algorithm/reverse.h>
+#include <__algorithm/reverse_copy.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/rotate_copy.h>
+#include <__algorithm/sample.h>
+#include <__algorithm/search.h>
+#include <__algorithm/search_n.h>
+#include <__algorithm/set_difference.h>
+#include <__algorithm/set_intersection.h>
+#include <__algorithm/set_symmetric_difference.h>
+#include <__algorithm/set_union.h>
+#include <__algorithm/shift_left.h>
+#include <__algorithm/shift_right.h>
+#include <__algorithm/shuffle.h>
+#include <__algorithm/sift_down.h>
+#include <__algorithm/sort.h>
+#include <__algorithm/sort_heap.h>
+#include <__algorithm/stable_partition.h>
+#include <__algorithm/stable_sort.h>
+#include <__algorithm/swap_ranges.h>
+#include <__algorithm/transform.h>
+#include <__algorithm/unique_copy.h>
+#include <__algorithm/unique.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__algorithm/upper_bound.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -666,5197 +761,10 @@ template <class BidirectionalIterator, class Compare>
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
-// * That only works with C++14 and later, and
-// * We haven't included <functional> here.
-template <class _T1, class _T2 = _T1>
-struct __equal_to
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
-};
-
-template <class _T1>
-struct __equal_to<_T1, _T1>
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
-};
-
-template <class _T1>
-struct __equal_to<const _T1, _T1>
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
-};
-
-template <class _T1>
-struct __equal_to<_T1, const _T1>
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
-};
-
-template <class _T1, class _T2 = _T1>
-struct __less
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
-};
-
-template <class _T1>
-struct __less<_T1, _T1>
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
-};
-
-template <class _T1>
-struct __less<const _T1, _T1>
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
-};
-
-template <class _T1>
-struct __less<_T1, const _T1>
-{
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
-};
-
-template <class _Predicate>
-class __invert // invert the sense of a comparison
-{
-private:
- _Predicate __p_;
-public:
- _LIBCPP_INLINE_VISIBILITY __invert() {}
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __invert(_Predicate __p) : __p_(__p) {}
-
- template <class _T1>
- _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _T1& __x) {return !__p_(__x);}
-
- template <class _T1, class _T2>
- _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
-};
-
-// Perform division by two quickly for positive integers (llvm.org/PR39129)
-
-template <typename _Integral>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_integral<_Integral>::value,
- _Integral
->::type
-__half_positive(_Integral __value)
-{
- return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
-}
-
-template <typename _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- !is_integral<_Tp>::value,
- _Tp
->::type
-__half_positive(_Tp __value)
-{
- return __value / 2;
-}
-
-#ifdef _LIBCPP_DEBUG
-
-template <class _Compare>
-struct __debug_less
-{
- _Compare &__comp_;
- _LIBCPP_CONSTEXPR_AFTER_CXX17
- __debug_less(_Compare& __c) : __comp_(__c) {}
-
- template <class _Tp, class _Up>
- _LIBCPP_CONSTEXPR_AFTER_CXX17
- bool operator()(const _Tp& __x, const _Up& __y)
- {
- bool __r = __comp_(__x, __y);
- if (__r)
- __do_compare_assert(0, __y, __x);
- return __r;
- }
-
- template <class _Tp, class _Up>
- _LIBCPP_CONSTEXPR_AFTER_CXX17
- bool operator()(_Tp& __x, _Up& __y)
- {
- bool __r = __comp_(__x, __y);
- if (__r)
- __do_compare_assert(0, __y, __x);
- return __r;
- }
-
- template <class _LHS, class _RHS>
- _LIBCPP_CONSTEXPR_AFTER_CXX17
- inline _LIBCPP_INLINE_VISIBILITY
- decltype((void)_VSTD::declval<_Compare&>()(
- _VSTD::declval<_LHS &>(), _VSTD::declval<_RHS &>()))
- __do_compare_assert(int, _LHS & __l, _RHS & __r) {
- _LIBCPP_ASSERT(!__comp_(__l, __r),
- "Comparator does not induce a strict weak ordering");
- }
-
- template <class _LHS, class _RHS>
- _LIBCPP_CONSTEXPR_AFTER_CXX17
- inline _LIBCPP_INLINE_VISIBILITY
- void __do_compare_assert(long, _LHS &, _RHS &) {}
-};
-
-#endif // _LIBCPP_DEBUG
-
-template <class _Comp>
-struct __comp_ref_type {
- // Pass the comparator by lvalue reference. Or in debug mode, using a
- // debugging wrapper that stores a reference.
-#ifndef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Comp>::type type;
-#else
- typedef __debug_less<_Comp> type;
-#endif
-};
-
-// all_of
-
-template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- if (!__pred(*__first))
- return false;
- return true;
-}
-
-// any_of
-
-template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- return true;
- return false;
-}
-
-// none_of
-
-template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- return false;
- return true;
-}
-
-// for_each
-
-template <class _InputIterator, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_Function
-for_each(_InputIterator __first, _InputIterator __last, _Function __f)
-{
- for (; __first != __last; ++__first)
- __f(*__first);
- return __f;
-}
-
-#if _LIBCPP_STD_VER > 14
-// for_each_n
-
-template <class _InputIterator, class _Size, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_InputIterator
-for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
-{
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
- _IntegralSize __n = __orig_n;
- while (__n > 0)
- {
- __f(*__first);
- ++__first;
- --__n;
- }
- return __first;
-}
-#endif
-
-// find
-
-template <class _InputIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_InputIterator
-find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
-{
- for (; __first != __last; ++__first)
- if (*__first == __value_)
- break;
- return __first;
-}
-
-// find_if
-
-template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_InputIterator
-find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- break;
- return __first;
-}
-
-// find_if_not
-
-template<class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_InputIterator
-find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- if (!__pred(*__first))
- break;
- return __first;
-}
-
-// find_end
-
-template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
-__find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
- forward_iterator_tag, forward_iterator_tag)
-{
- // modeled after search algorithm
- _ForwardIterator1 __r = __last1; // __last1 is the "default" answer
- if (__first2 == __last2)
- return __r;
- while (true)
- {
- while (true)
- {
- if (__first1 == __last1) // if source exhausted return last correct answer
- return __r; // (or __last1 if never found)
- if (__pred(*__first1, *__first2))
- break;
- ++__first1;
- }
- // *__first1 matches *__first2, now match elements after here
- _ForwardIterator1 __m1 = __first1;
- _ForwardIterator2 __m2 = __first2;
- while (true)
- {
- if (++__m2 == __last2)
- { // Pattern exhaused, record answer and search for another one
- __r = __first1;
- ++__first1;
- break;
- }
- if (++__m1 == __last1) // Source exhausted, return last answer
- return __r;
- if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first
- {
- ++__first1;
- break;
- } // else there is a match, check next elements
- }
- }
-}
-
-template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1
-__find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1,
- _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BinaryPredicate __pred,
- bidirectional_iterator_tag, bidirectional_iterator_tag)
-{
- // modeled after search algorithm (in reverse)
- if (__first2 == __last2)
- return __last1; // Everything matches an empty sequence
- _BidirectionalIterator1 __l1 = __last1;
- _BidirectionalIterator2 __l2 = __last2;
- --__l2;
- while (true)
- {
- // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
- while (true)
- {
- if (__first1 == __l1) // return __last1 if no element matches *__first2
- return __last1;
- if (__pred(*--__l1, *__l2))
- break;
- }
- // *__l1 matches *__l2, now match elements before here
- _BidirectionalIterator1 __m1 = __l1;
- _BidirectionalIterator2 __m2 = __l2;
- while (true)
- {
- if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
- return __m1;
- if (__m1 == __first1) // Otherwise if source exhaused, pattern not found
- return __last1;
- if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1
- {
- break;
- } // else there is a match, check next elements
- }
- }
-}
-
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
-__find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
- _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
- random_access_iterator_tag, random_access_iterator_tag)
-{
- // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
- typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2;
- if (__len2 == 0)
- return __last1;
- typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1;
- if (__len1 < __len2)
- return __last1;
- const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here
- _RandomAccessIterator1 __l1 = __last1;
- _RandomAccessIterator2 __l2 = __last2;
- --__l2;
- while (true)
- {
- while (true)
- {
- if (__s == __l1)
- return __last1;
- if (__pred(*--__l1, *__l2))
- break;
- }
- _RandomAccessIterator1 __m1 = __l1;
- _RandomAccessIterator2 __m2 = __l2;
- while (true)
- {
- if (__m2 == __first2)
- return __m1;
- // no need to check range on __m1 because __s guarantees we have enough source
- if (!__pred(*--__m1, *--__m2))
- {
- break;
- }
- }
- }
-}
-
-template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator1
-find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
-{
- return _VSTD::__find_end<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first1, __last1, __first2, __last2, __pred,
- typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
-}
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator1
-find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2)
-{
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
-}
-
-// find_first_of
-
-template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1
-__find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
-{
- for (; __first1 != __last1; ++__first1)
- for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
- if (__pred(*__first1, *__j))
- return __first1;
- return __last1;
-}
-
-
-template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator1
-find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
-{
- return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
-}
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator1
-find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2)
-{
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
-}
-
-// adjacent_find
-
-template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
-{
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- {
- if (__pred(*__first, *__i))
- return __first;
- __first = __i;
- }
- }
- return __last;
-}
-
-template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
-}
-
-// count
-
-template <class _InputIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename iterator_traits<_InputIterator>::difference_type
-count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
-{
- typename iterator_traits<_InputIterator>::difference_type __r(0);
- for (; __first != __last; ++__first)
- if (*__first == __value_)
- ++__r;
- return __r;
-}
-
-// count_if
-
-template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename iterator_traits<_InputIterator>::difference_type
-count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- typename iterator_traits<_InputIterator>::difference_type __r(0);
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- ++__r;
- return __r;
-}
-
-// mismatch
-
-template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_InputIterator1, _InputIterator2>
-mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _BinaryPredicate __pred)
-{
- for (; __first1 != __last1; ++__first1, (void) ++__first2)
- if (!__pred(*__first1, *__first2))
- break;
- return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
-}
-
-template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_InputIterator1, _InputIterator2>
-mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
-{
- typedef typename iterator_traits<_InputIterator1>::value_type __v1;
- typedef typename iterator_traits<_InputIterator2>::value_type __v2;
- return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
-}
-
-#if _LIBCPP_STD_VER > 11
-template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_InputIterator1, _InputIterator2>
-mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _BinaryPredicate __pred)
-{
- for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
- if (!__pred(*__first1, *__first2))
- break;
- return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
-}
-
-template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_InputIterator1, _InputIterator2>
-mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2)
-{
- typedef typename iterator_traits<_InputIterator1>::value_type __v1;
- typedef typename iterator_traits<_InputIterator2>::value_type __v2;
- return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
-}
-#endif
-
-// equal
-
-template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred)
-{
- for (; __first1 != __last1; ++__first1, (void) ++__first2)
- if (!__pred(*__first1, *__first2))
- return false;
- return true;
-}
-
-template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
-{
- typedef typename iterator_traits<_InputIterator1>::value_type __v1;
- typedef typename iterator_traits<_InputIterator2>::value_type __v2;
- return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
-}
-
-#if _LIBCPP_STD_VER > 11
-template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-__equal(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
- input_iterator_tag, input_iterator_tag )
-{
- for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
- if (!__pred(*__first1, *__first2))
- return false;
- return __first1 == __last1 && __first2 == __last2;
-}
-
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
- _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
- random_access_iterator_tag, random_access_iterator_tag )
-{
- if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
- return false;
- return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2,
- typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first1, __last1, __first2, __pred );
-}
-
-template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-equal(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
-{
- return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first1, __last1, __first2, __last2, __pred,
- typename iterator_traits<_InputIterator1>::iterator_category(),
- typename iterator_traits<_InputIterator2>::iterator_category());
-}
-
-template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-equal(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2)
-{
- typedef typename iterator_traits<_InputIterator1>::value_type __v1;
- typedef typename iterator_traits<_InputIterator2>::value_type __v2;
- return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
- typename iterator_traits<_InputIterator1>::iterator_category(),
- typename iterator_traits<_InputIterator2>::iterator_category());
-}
-#endif
-
-// is_permutation
-
-template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _BinaryPredicate __pred)
-{
-// shorten sequences as much as possible by lopping of any equal prefix
- for (; __first1 != __last1; ++__first1, (void) ++__first2)
- if (!__pred(*__first1, *__first2))
- break;
- if (__first1 == __last1)
- return true;
-
-// __first1 != __last1 && *__first1 != *__first2
- typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
- _D1 __l1 = _VSTD::distance(__first1, __last1);
- if (__l1 == _D1(1))
- return false;
- _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1);
- // For each element in [f1, l1) see if there are the same number of
- // equal elements in [f2, l2)
- for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
- {
- // Have we already counted the number of *__i in [f1, l1)?
- _ForwardIterator1 __match = __first1;
- for (; __match != __i; ++__match)
- if (__pred(*__match, *__i))
- break;
- if (__match == __i) {
- // Count number of *__i in [f2, l2)
- _D1 __c2 = 0;
- for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
- if (__pred(*__i, *__j))
- ++__c2;
- if (__c2 == 0)
- return false;
- // Count number of *__i in [__i, l1) (we can start with 1)
- _D1 __c1 = 1;
- for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
- if (__pred(*__i, *__j))
- ++__c1;
- if (__c1 != __c2)
- return false;
- }
- }
- return true;
-}
-
-template<class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2)
-{
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
-}
-
-#if _LIBCPP_STD_VER > 11
-template<class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __pred,
- forward_iterator_tag, forward_iterator_tag )
-{
-// shorten sequences as much as possible by lopping of any equal prefix
- for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void) ++__first2)
- if (!__pred(*__first1, *__first2))
- break;
- if (__first1 == __last1)
- return __first2 == __last2;
- else if (__first2 == __last2)
- return false;
-
- typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
- _D1 __l1 = _VSTD::distance(__first1, __last1);
-
- typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
- _D2 __l2 = _VSTD::distance(__first2, __last2);
- if (__l1 != __l2)
- return false;
-
- // For each element in [f1, l1) see if there are the same number of
- // equal elements in [f2, l2)
- for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
- {
- // Have we already counted the number of *__i in [f1, l1)?
- _ForwardIterator1 __match = __first1;
- for (; __match != __i; ++__match)
- if (__pred(*__match, *__i))
- break;
- if (__match == __i) {
- // Count number of *__i in [f2, l2)
- _D1 __c2 = 0;
- for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
- if (__pred(*__i, *__j))
- ++__c2;
- if (__c2 == 0)
- return false;
- // Count number of *__i in [__i, l1) (we can start with 1)
- _D1 __c1 = 1;
- for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
- if (__pred(*__i, *__j))
- ++__c1;
- if (__c1 != __c2)
- return false;
- }
- }
- return true;
-}
-
-template<class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
- _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
- _BinaryPredicate __pred,
- random_access_iterator_tag, random_access_iterator_tag )
-{
- if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
- return false;
- return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
- typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first1, __last1, __first2, __pred );
-}
-
-template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2,
- _BinaryPredicate __pred )
-{
- return _VSTD::__is_permutation<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first1, __last1, __first2, __last2, __pred,
- typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
-}
-
-template<class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2)
-{
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::__is_permutation(__first1, __last1, __first2, __last2,
- __equal_to<__v1, __v2>(),
- typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category());
-}
-#endif
-
-// search
-// __search is in <functional>
-
-template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator1
-search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
-{
- return _VSTD::__search<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first1, __last1, __first2, __last2, __pred,
- typename iterator_traits<_ForwardIterator1>::iterator_category(),
- typename iterator_traits<_ForwardIterator2>::iterator_category())
- .first;
-}
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator1
-search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2)
-{
- typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
- typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
- return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
-}
-
-
-#if _LIBCPP_STD_VER > 14
-template <class _ForwardIterator, class _Searcher>
-_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
-{ return __s(__f, __l).first; }
-#endif
-
-// search_n
-
-template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Size __count, const _Tp& __value_, _BinaryPredicate __pred, forward_iterator_tag)
-{
- if (__count <= 0)
- return __first;
- while (true)
- {
- // Find first element in sequence that matchs __value_, with a mininum of loop checks
- while (true)
- {
- if (__first == __last) // return __last if no element matches __value_
- return __last;
- if (__pred(*__first, __value_))
- break;
- ++__first;
- }
- // *__first matches __value_, now match elements after here
- _ForwardIterator __m = __first;
- _Size __c(0);
- while (true)
- {
- if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
- return __first;
- if (++__m == __last) // Otherwise if source exhaused, pattern not found
- return __last;
- if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
- {
- __first = __m;
- ++__first;
- break;
- } // else there is a match, check next elements
- }
- }
-}
-
-template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-__search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag)
-{
- if (__count <= 0)
- return __first;
- _Size __len = static_cast<_Size>(__last - __first);
- if (__len < __count)
- return __last;
- const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here
- while (true)
- {
- // Find first element in sequence that matchs __value_, with a mininum of loop checks
- while (true)
- {
- if (__first >= __s) // return __last if no element matches __value_
- return __last;
- if (__pred(*__first, __value_))
- break;
- ++__first;
- }
- // *__first matches __value_, now match elements after here
- _RandomAccessIterator __m = __first;
- _Size __c(0);
- while (true)
- {
- if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern)
- return __first;
- ++__m; // no need to check range on __m because __s guarantees we have enough source
- if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first
- {
- __first = __m;
- ++__first;
- break;
- } // else there is a match, check next elements
- }
- }
-}
-
-template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-search_n(_ForwardIterator __first, _ForwardIterator __last,
- _Size __count, const _Tp& __value_, _BinaryPredicate __pred)
-{
- return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
- typename iterator_traits<_ForwardIterator>::iterator_category());
-}
-
-template <class _ForwardIterator, class _Size, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count),
- __value_, __equal_to<__v, _Tp>());
-}
-
-// copy
-template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-_Iter
-__unwrap_iter(_Iter __i)
-{
- return __i;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_trivially_copy_assignable<_Tp>::value,
- _Tp*
->::type
-__unwrap_iter(move_iterator<_Tp*> __i)
-{
- return __i.base();
-}
-
-#if _LIBCPP_DEBUG_LEVEL < 2
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_trivially_copy_assignable<_Tp>::value,
- _Tp*
->::type
-__unwrap_iter(__wrap_iter<_Tp*> __i)
-{
- return __i.base();
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_trivially_copy_assignable<_Tp>::value,
- const _Tp*
->::type
-__unwrap_iter(__wrap_iter<const _Tp*> __i)
-{
- return __i.base();
-}
-
-#else
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_trivially_copy_assignable<_Tp>::value,
- __wrap_iter<_Tp*>
->::type
-__unwrap_iter(__wrap_iter<_Tp*> __i)
-{
- return __i;
-}
-
-#endif // _LIBCPP_DEBUG_LEVEL < 2
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = *__first;
- return __result;
-}
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__copy_constexpr(__first, __last, __result);
-}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__copy(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- return __result + __n;
-}
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_constexpr(
- _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
- } else {
- return _VSTD::__copy(
- _VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
- }
-}
-
-// copy_backward
-
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- while (__first != __last)
- *--__result = *--__last;
- return __result;
-}
-
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- return _VSTD::__copy_backward_constexpr(__first, __last, __result);
-}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- {
- __result -= __n;
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- }
- return __result;
-}
-
-template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_BidirectionalIterator2
-copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
- _BidirectionalIterator2 __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_backward_constexpr(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result));
- } else {
- return _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result));
- }
-}
-
-// copy_if
-
-template<class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-copy_if(_InputIterator __first, _InputIterator __last,
- _OutputIterator __result, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- {
- if (__pred(*__first))
- {
- *__result = *__first;
- ++__result;
- }
- }
- return __result;
-}
-
-// copy_n
-
-template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIterator>::value &&
- !__is_cpp17_random_access_iterator<_InputIterator>::value,
- _OutputIterator
->::type
-copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
-{
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
- _IntegralSize __n = __orig_n;
- if (__n > 0)
- {
- *__result = *__first;
- ++__result;
- for (--__n; __n > 0; --__n)
- {
- ++__first;
- *__result = *__first;
- ++__result;
- }
- }
- return __result;
-}
-
-template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename enable_if
-<
- __is_cpp17_random_access_iterator<_InputIterator>::value,
- _OutputIterator
->::type
-copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
-{
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
- _IntegralSize __n = __orig_n;
- return _VSTD::copy(__first, __first + __n, __result);
-}
-
-// move
-
-// __move_constexpr exists so that __move doesn't call itself when delegating to the constexpr
-// version of __move.
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = _VSTD::move(*__first);
- return __result;
-}
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__move_constexpr(__first, __last, __result);
-}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__move(_Tp* __first, _Tp* __last, _Up* __result)
-{
- if (__libcpp_is_constant_evaluated())
- return _VSTD::__move_constexpr(__first, __last, __result);
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- return __result + __n;
-}
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__move(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
-}
-
-// move_backward
-
-// __move_backward_constexpr exists so that __move_backward doesn't call itself when delegating to
-// the constexpr version of __move_backward.
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- while (__first != __last)
- *--__result = _VSTD::move(*--__last);
- return __result;
-}
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_OutputIterator
-__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__move_backward_constexpr(__first, __last, __result);
-}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
-{
- if (__libcpp_is_constant_evaluated())
- return _VSTD::__move_backward_constexpr(__first, __last, __result);
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- {
- __result -= __n;
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- }
- return __result;
-}
-
-template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_BidirectionalIterator2
-move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
- _BidirectionalIterator2 __result)
-{
- return _VSTD::__move_backward(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _VSTD::__unwrap_iter(__result));
-}
-
-// iter_swap
-
-// moved to <type_traits> for better swap / noexcept support
-
-// transform
-
-template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = __op(*__first);
- return __result;
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
- _OutputIterator __result, _BinaryOperation __binary_op)
-{
- for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result)
- *__result = __binary_op(*__first1, *__first2);
- return __result;
-}
-
-// replace
-
-template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
-{
- for (; __first != __last; ++__first)
- if (*__first == __old_value)
- *__first = __new_value;
-}
-
-// replace_if
-
-template <class _ForwardIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
-{
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- *__first = __new_value;
-}
-
-// replace_copy
-
-template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
- const _Tp& __old_value, const _Tp& __new_value)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- if (*__first == __old_value)
- *__result = __new_value;
- else
- *__result = *__first;
- return __result;
-}
-
-// replace_copy_if
-
-template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
- _Predicate __pred, const _Tp& __new_value)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- if (__pred(*__first))
- *__result = __new_value;
- else
- *__result = *__first;
- return __result;
-}
-
-// fill_n
-
-template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
-{
- for (; __n > 0; ++__first, (void) --__n)
- *__first = __value_;
- return __first;
-}
-
-template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
-{
- return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
-}
-
-// fill
-
-template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
-{
- for (; __first != __last; ++__first)
- *__first = __value_;
-}
-
-template <class _RandomAccessIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
-{
- _VSTD::fill_n(__first, __last - __first, __value_);
-}
-
-template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
-}
-
-// generate
-
-template <class _ForwardIterator, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
-{
- for (; __first != __last; ++__first)
- *__first = __gen();
-}
-
-// generate_n
-
-template <class _OutputIterator, class _Size, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
-{
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
- _IntegralSize __n = __orig_n;
- for (; __n > 0; ++__first, (void) --__n)
- *__first = __gen();
- return __first;
-}
-
-// remove
-
-template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- __first = _VSTD::find(__first, __last, __value_);
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- {
- if (!(*__i == __value_))
- {
- *__first = _VSTD::move(*__i);
- ++__first;
- }
- }
- }
- return __first;
-}
-
-// remove_if
-
-template <class _ForwardIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
-{
- __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type>
- (__first, __last, __pred);
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- {
- if (!__pred(*__i))
- {
- *__first = _VSTD::move(*__i);
- ++__first;
- }
- }
- }
- return __first;
-}
-
-// remove_copy
-
-template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
-{
- for (; __first != __last; ++__first)
- {
- if (!(*__first == __value_))
- {
- *__result = *__first;
- ++__result;
- }
- }
- return __result;
-}
-
-// remove_copy_if
-
-template <class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- {
- if (!__pred(*__first))
- {
- *__result = *__first;
- ++__result;
- }
- }
- return __result;
-}
-
-// unique
-
-template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
-{
- __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first, __last, __pred);
- if (__first != __last)
- {
- // ... a a ? ...
- // f i
- _ForwardIterator __i = __first;
- for (++__i; ++__i != __last;)
- if (!__pred(*__first, *__i))
- *++__first = _VSTD::move(*__i);
- ++__first;
- }
- return __first;
-}
-
-template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-unique(_ForwardIterator __first, _ForwardIterator __last)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::unique(__first, __last, __equal_to<__v>());
-}
-
-// unique_copy
-
-template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
- input_iterator_tag, output_iterator_tag)
-{
- if (__first != __last)
- {
- typename iterator_traits<_InputIterator>::value_type __t(*__first);
- *__result = __t;
- ++__result;
- while (++__first != __last)
- {
- if (!__pred(__t, *__first))
- {
- __t = *__first;
- *__result = __t;
- ++__result;
- }
- }
- }
- return __result;
-}
-
-template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
- forward_iterator_tag, output_iterator_tag)
-{
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- *__result = *__i;
- ++__result;
- while (++__first != __last)
- {
- if (!__pred(*__i, *__first))
- {
- *__result = *__first;
- ++__result;
- __i = __first;
- }
- }
- }
- return __result;
-}
-
-template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
- input_iterator_tag, forward_iterator_tag)
-{
- if (__first != __last)
- {
- *__result = *__first;
- while (++__first != __last)
- if (!__pred(*__result, *__first))
- *++__result = *__first;
- ++__result;
- }
- return __result;
-}
-
-template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
-{
- return _VSTD::__unique_copy<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first, __last, __result, __pred,
- typename iterator_traits<_InputIterator>::iterator_category(),
- typename iterator_traits<_OutputIterator>::iterator_category());
-}
-
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- typedef typename iterator_traits<_InputIterator>::value_type __v;
- return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
-}
-
-// reverse
-
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
-{
- while (__first != __last)
- {
- if (__first == --__last)
- break;
- _VSTD::iter_swap(__first, __last);
- ++__first;
- }
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
-{
- if (__first != __last)
- for (; __first < --__last; ++__first)
- _VSTD::iter_swap(__first, __last);
-}
-
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
-{
- _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category());
-}
-
-// reverse_copy
-
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__result)
- *__result = *--__last;
- return __result;
-}
-
-// rotate
-
-template <class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
-__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- value_type __tmp = _VSTD::move(*__first);
- _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
- *__lm1 = _VSTD::move(__tmp);
- return __lm1;
-}
-
-template <class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
-__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- _BidirectionalIterator __lm1 = _VSTD::prev(__last);
- value_type __tmp = _VSTD::move(*__lm1);
- _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
- *__first = _VSTD::move(__tmp);
- return __fp1;
-}
-
-template <class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
-__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
-{
- _ForwardIterator __i = __middle;
- while (true)
- {
- swap(*__first, *__i);
- ++__first;
- if (++__i == __last)
- break;
- if (__first == __middle)
- __middle = __i;
- }
- _ForwardIterator __r = __first;
- if (__first != __middle)
- {
- __i = __middle;
- while (true)
- {
- swap(*__first, *__i);
- ++__first;
- if (++__i == __last)
- {
- if (__first == __middle)
- break;
- __i = __middle;
- }
- else if (__first == __middle)
- __middle = __i;
- }
- }
- return __r;
-}
-
-template<typename _Integral>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
-__algo_gcd(_Integral __x, _Integral __y)
-{
- do
- {
- _Integral __t = __x % __y;
- __x = __y;
- __y = __t;
- } while (__y);
- return __x;
-}
-
-template<typename _RandomAccessIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
-__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
-
- const difference_type __m1 = __middle - __first;
- const difference_type __m2 = __last - __middle;
- if (__m1 == __m2)
- {
- _VSTD::swap_ranges(__first, __middle, __middle);
- return __middle;
- }
- const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
- for (_RandomAccessIterator __p = __first + __g; __p != __first;)
- {
- value_type __t(_VSTD::move(*--__p));
- _RandomAccessIterator __p1 = __p;
- _RandomAccessIterator __p2 = __p1 + __m1;
- do
- {
- *__p1 = _VSTD::move(*__p2);
- __p1 = __p2;
- const difference_type __d = __last - __p2;
- if (__m1 < __d)
- __p2 += __m1;
- else
- __p2 = __first + (__m1 - __d);
- } while (__p2 != __p);
- *__p1 = _VSTD::move(__t);
- }
- return __first + __m2;
-}
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
-__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
- _VSTD::forward_iterator_tag)
-{
- typedef typename _VSTD::iterator_traits<_ForwardIterator>::value_type value_type;
- if (_VSTD::is_trivially_move_assignable<value_type>::value)
- {
- if (_VSTD::next(__first) == __middle)
- return _VSTD::__rotate_left(__first, __last);
- }
- return _VSTD::__rotate_forward(__first, __middle, __last);
-}
-
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
-__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _VSTD::bidirectional_iterator_tag)
-{
- typedef typename _VSTD::iterator_traits<_BidirectionalIterator>::value_type value_type;
- if (_VSTD::is_trivially_move_assignable<value_type>::value)
- {
- if (_VSTD::next(__first) == __middle)
- return _VSTD::__rotate_left(__first, __last);
- if (_VSTD::next(__middle) == __last)
- return _VSTD::__rotate_right(__first, __last);
- }
- return _VSTD::__rotate_forward(__first, __middle, __last);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
-__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
- _VSTD::random_access_iterator_tag)
-{
- typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::value_type value_type;
- if (_VSTD::is_trivially_move_assignable<value_type>::value)
- {
- if (_VSTD::next(__first) == __middle)
- return _VSTD::__rotate_left(__first, __last);
- if (_VSTD::next(__middle) == __last)
- return _VSTD::__rotate_right(__first, __last);
- return _VSTD::__rotate_gcd(__first, __middle, __last);
- }
- return _VSTD::__rotate_forward(__first, __middle, __last);
-}
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
-{
- if (__first == __middle)
- return __last;
- if (__middle == __last)
- return __first;
- return _VSTD::__rotate(__first, __middle, __last,
- typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category());
-}
-
-// rotate_copy
-
-template <class _ForwardIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
-{
- return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result));
-}
-
-// min_element
-
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
- static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "std::min_element requires a ForwardIterator");
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- if (__comp(*__i, *__first))
- __first = __i;
- }
- return __first;
-}
-
-template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-min_element(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::min_element(__first, __last,
- __less<typename iterator_traits<_ForwardIterator>::value_type>());
-}
-
-// min
-
-template <class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-const _Tp&
-min(const _Tp& __a, const _Tp& __b, _Compare __comp)
-{
- return __comp(__b, __a) ? __b : __a;
-}
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-const _Tp&
-min(const _Tp& __a, const _Tp& __b)
-{
- return _VSTD::min(__a, __b, __less<_Tp>());
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp
-min(initializer_list<_Tp> __t, _Compare __comp)
-{
- return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
-}
-
-template<class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp
-min(initializer_list<_Tp> __t)
-{
- return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-// max_element
-
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
- static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "std::max_element requires a ForwardIterator");
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- if (__comp(*__first, *__i))
- __first = __i;
- }
- return __first;
-}
-
-
-template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-max_element(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::max_element(__first, __last,
- __less<typename iterator_traits<_ForwardIterator>::value_type>());
-}
-
-// max
-
-template <class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-const _Tp&
-max(const _Tp& __a, const _Tp& __b, _Compare __comp)
-{
- return __comp(__a, __b) ? __b : __a;
-}
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-const _Tp&
-max(const _Tp& __a, const _Tp& __b)
-{
- return _VSTD::max(__a, __b, __less<_Tp>());
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp
-max(initializer_list<_Tp> __t, _Compare __comp)
-{
- return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
-}
-
-template<class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp
-max(initializer_list<_Tp> __t)
-{
- return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-#if _LIBCPP_STD_VER > 14
-// clamp
-template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-const _Tp&
-clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
-{
- _LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
- return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
-
-}
-
-template<class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-const _Tp&
-clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
-{
- return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>());
-}
-#endif
-
-// minmax_element
-
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_ForwardIterator, _ForwardIterator>
-minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
- static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "std::minmax_element requires a ForwardIterator");
- pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
- if (__first != __last)
- {
- if (++__first != __last)
- {
- if (__comp(*__first, *__result.first))
- __result.first = __first;
- else
- __result.second = __first;
- while (++__first != __last)
- {
- _ForwardIterator __i = __first;
- if (++__first == __last)
- {
- if (__comp(*__i, *__result.first))
- __result.first = __i;
- else if (!__comp(*__i, *__result.second))
- __result.second = __i;
- break;
- }
- else
- {
- if (__comp(*__first, *__i))
- {
- if (__comp(*__first, *__result.first))
- __result.first = __first;
- if (!__comp(*__i, *__result.second))
- __result.second = __i;
- }
- else
- {
- if (__comp(*__i, *__result.first))
- __result.first = __i;
- if (!__comp(*__first, *__result.second))
- __result.second = __first;
- }
- }
- }
- }
- }
- return __result;
-}
-
-template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_ForwardIterator, _ForwardIterator>
-minmax_element(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::minmax_element(__first, __last,
- __less<typename iterator_traits<_ForwardIterator>::value_type>());
-}
-
-// minmax
-
-template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<const _Tp&, const _Tp&>
-minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
-{
- return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) :
- pair<const _Tp&, const _Tp&>(__a, __b);
-}
-
-template<class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<const _Tp&, const _Tp&>
-minmax(const _Tp& __a, const _Tp& __b)
-{
- return _VSTD::minmax(__a, __b, __less<_Tp>());
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_Tp, _Tp>
-minmax(initializer_list<_Tp> __t, _Compare __comp)
-{
- typedef typename initializer_list<_Tp>::const_iterator _Iter;
- _Iter __first = __t.begin();
- _Iter __last = __t.end();
- pair<_Tp, _Tp> __result(*__first, *__first);
-
- ++__first;
- if (__t.size() % 2 == 0)
- {
- if (__comp(*__first, __result.first))
- __result.first = *__first;
- else
- __result.second = *__first;
- ++__first;
- }
-
- while (__first != __last)
- {
- _Tp __prev = *__first++;
- if (__comp(*__first, __prev)) {
- if ( __comp(*__first, __result.first)) __result.first = *__first;
- if (!__comp(__prev, __result.second)) __result.second = __prev;
- }
- else {
- if ( __comp(__prev, __result.first)) __result.first = __prev;
- if (!__comp(*__first, __result.second)) __result.second = *__first;
- }
-
- __first++;
- }
- return __result;
-}
-
-template<class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_Tp, _Tp>
-minmax(initializer_list<_Tp> __t)
-{
- return _VSTD::minmax(__t, __less<_Tp>());
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-// random_shuffle
-
-// __independent_bits_engine
-
-template <unsigned long long _Xp, size_t _Rp>
-struct __log2_imp
-{
- static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp
- : __log2_imp<_Xp, _Rp - 1>::value;
-};
-
-template <unsigned long long _Xp>
-struct __log2_imp<_Xp, 0>
-{
- static const size_t value = 0;
-};
-
-template <size_t _Rp>
-struct __log2_imp<0, _Rp>
-{
- static const size_t value = _Rp + 1;
-};
-
-template <class _UIntType, _UIntType _Xp>
-struct __log2
-{
- static const size_t value = __log2_imp<_Xp,
- sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
-};
-
-template<class _Engine, class _UIntType>
-class __independent_bits_engine
-{
-public:
- // types
- typedef _UIntType result_type;
-
-private:
- typedef typename _Engine::result_type _Engine_result_type;
- typedef typename conditional
- <
- sizeof(_Engine_result_type) <= sizeof(result_type),
- result_type,
- _Engine_result_type
- >::type _Working_result_type;
-
- _Engine& __e_;
- size_t __w_;
- size_t __w0_;
- size_t __n_;
- size_t __n0_;
- _Working_result_type __y0_;
- _Working_result_type __y1_;
- _Engine_result_type __mask0_;
- _Engine_result_type __mask1_;
-
-#ifdef _LIBCPP_CXX03_LANG
- static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
- + _Working_result_type(1);
-#else
- static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
- + _Working_result_type(1);
-#endif
- static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value;
- static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits;
- static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits;
-
-public:
- // constructors and seeding functions
- __independent_bits_engine(_Engine& __e, size_t __w);
-
- // generating functions
- result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
-
-private:
- result_type __eval(false_type);
- result_type __eval(true_type);
-};
-
-template<class _Engine, class _UIntType>
-__independent_bits_engine<_Engine, _UIntType>
- ::__independent_bits_engine(_Engine& __e, size_t __w)
- : __e_(__e),
- __w_(__w)
-{
- __n_ = __w_ / __m + (__w_ % __m != 0);
- __w0_ = __w_ / __n_;
- if (_Rp == 0)
- __y0_ = _Rp;
- else if (__w0_ < _WDt)
- __y0_ = (_Rp >> __w0_) << __w0_;
- else
- __y0_ = 0;
- if (_Rp - __y0_ > __y0_ / __n_)
- {
- ++__n_;
- __w0_ = __w_ / __n_;
- if (__w0_ < _WDt)
- __y0_ = (_Rp >> __w0_) << __w0_;
- else
- __y0_ = 0;
- }
- __n0_ = __n_ - __w_ % __n_;
- if (__w0_ < _WDt - 1)
- __y1_ = (_Rp >> (__w0_ + 1)) << (__w0_ + 1);
- else
- __y1_ = 0;
- __mask0_ = __w0_ > 0 ? _Engine_result_type(~0) >> (_EDt - __w0_) :
- _Engine_result_type(0);
- __mask1_ = __w0_ < _EDt - 1 ?
- _Engine_result_type(~0) >> (_EDt - (__w0_ + 1)) :
- _Engine_result_type(~0);
-}
-
-template<class _Engine, class _UIntType>
-inline
-_UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
-{
- return static_cast<result_type>(__e_() & __mask0_);
-}
-
-template<class _Engine, class _UIntType>
-_UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
-{
- const size_t _WRt = numeric_limits<result_type>::digits;
- result_type _Sp = 0;
- for (size_t __k = 0; __k < __n0_; ++__k)
- {
- _Engine_result_type __u;
- do
- {
- __u = __e_() - _Engine::min();
- } while (__u >= __y0_);
- if (__w0_ < _WRt)
- _Sp <<= __w0_;
- else
- _Sp = 0;
- _Sp += __u & __mask0_;
- }
- for (size_t __k = __n0_; __k < __n_; ++__k)
- {
- _Engine_result_type __u;
- do
- {
- __u = __e_() - _Engine::min();
- } while (__u >= __y1_);
- if (__w0_ < _WRt - 1)
- _Sp <<= __w0_ + 1;
- else
- _Sp = 0;
- _Sp += __u & __mask1_;
- }
- return _Sp;
-}
-
-// uniform_int_distribution
-
-template<class _IntType = int>
-class uniform_int_distribution
-{
-public:
- // types
- typedef _IntType result_type;
-
- class param_type
- {
- result_type __a_;
- result_type __b_;
- public:
- typedef uniform_int_distribution distribution_type;
-
- explicit param_type(result_type __a = 0,
- result_type __b = numeric_limits<result_type>::max())
- : __a_(__a), __b_(__b) {}
-
- result_type a() const {return __a_;}
- result_type b() const {return __b_;}
-
- friend bool operator==(const param_type& __x, const param_type& __y)
- {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
- friend bool operator!=(const param_type& __x, const param_type& __y)
- {return !(__x == __y);}
- };
-
-private:
- param_type __p_;
-
-public:
- // constructors and reset functions
-#ifndef _LIBCPP_CXX03_LANG
- uniform_int_distribution() : uniform_int_distribution(0) {}
- explicit uniform_int_distribution(
- result_type __a, result_type __b = numeric_limits<result_type>::max())
- : __p_(param_type(__a, __b)) {}
-#else
- explicit uniform_int_distribution(
- result_type __a = 0,
- result_type __b = numeric_limits<result_type>::max())
- : __p_(param_type(__a, __b)) {}
-#endif
- explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {}
- void reset() {}
-
- // generating functions
- template<class _URNG> result_type operator()(_URNG& __g)
- {return (*this)(__g, __p_);}
- template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
-
- // property functions
- result_type a() const {return __p_.a();}
- result_type b() const {return __p_.b();}
-
- param_type param() const {return __p_;}
- void param(const param_type& __p) {__p_ = __p;}
-
- result_type min() const {return a();}
- result_type max() const {return b();}
-
- friend bool operator==(const uniform_int_distribution& __x,
- const uniform_int_distribution& __y)
- {return __x.__p_ == __y.__p_;}
- friend bool operator!=(const uniform_int_distribution& __x,
- const uniform_int_distribution& __y)
- {return !(__x == __y);}
-};
-
-template<class _IntType>
-template<class _URNG>
-typename uniform_int_distribution<_IntType>::result_type
-uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
-_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
-{
- typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t),
- uint32_t, uint64_t>::type _UIntType;
- const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
- if (_Rp == 1)
- return __p.a();
- const size_t _Dt = numeric_limits<_UIntType>::digits;
- typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
- if (_Rp == 0)
- return static_cast<result_type>(_Eng(__g, _Dt)());
- size_t __w = _Dt - __libcpp_clz(_Rp) - 1;
- if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
- ++__w;
- _Eng __e(__g, __w);
- _UIntType __u;
- do
- {
- __u = __e();
- } while (__u >= _Rp);
- return static_cast<result_type>(__u + __p.a());
-}
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \
- || defined(_LIBCPP_BUILDING_LIBRARY)
-class _LIBCPP_TYPE_VIS __rs_default;
-
-_LIBCPP_FUNC_VIS __rs_default __rs_get();
-
-class _LIBCPP_TYPE_VIS __rs_default
-{
- static unsigned __c_;
-
- __rs_default();
-public:
- typedef uint_fast32_t result_type;
-
- static const result_type _Min = 0;
- static const result_type _Max = 0xFFFFFFFF;
-
- __rs_default(const __rs_default&);
- ~__rs_default();
-
- result_type operator()();
-
- static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
- static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
-
- friend _LIBCPP_FUNC_VIS __rs_default __rs_get();
-};
-
-_LIBCPP_FUNC_VIS __rs_default __rs_get();
-
-template <class _RandomAccessIterator>
-_LIBCPP_DEPRECATED_IN_CXX14 void
-random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef uniform_int_distribution<ptrdiff_t> _Dp;
- typedef typename _Dp::param_type _Pp;
- difference_type __d = __last - __first;
- if (__d > 1)
- {
- _Dp __uid;
- __rs_default __g = __rs_get();
- for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
- {
- difference_type __i = __uid(__g, _Pp(0, __d));
- if (__i != difference_type(0))
- swap(*__first, *(__first + __i));
- }
- }
-}
-
-template <class _RandomAccessIterator, class _RandomNumberGenerator>
-_LIBCPP_DEPRECATED_IN_CXX14 void
-random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
-#ifndef _LIBCPP_CXX03_LANG
- _RandomNumberGenerator&& __rand)
-#else
- _RandomNumberGenerator& __rand)
-#endif
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __d = __last - __first;
- if (__d > 1)
- {
- for (--__last; __first < __last; ++__first, (void) --__d)
- {
- difference_type __i = __rand(__d);
- if (__i != difference_type(0))
- swap(*__first, *(__first + __i));
- }
- }
-}
-#endif
-
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
- class _UniformRandomNumberGenerator>
-_LIBCPP_INLINE_VISIBILITY
-_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
- _Distance __n,
- _UniformRandomNumberGenerator & __g,
- input_iterator_tag) {
-
- _Distance __k = 0;
- for (; __first != __last && __k < __n; ++__first, (void) ++__k)
- __output_iter[__k] = *__first;
- _Distance __sz = __k;
- for (; __first != __last; ++__first, (void) ++__k) {
- _Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
- if (__r < __sz)
- __output_iter[__r] = *__first;
- }
- return __output_iter + _VSTD::min(__n, __k);
-}
-
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
- class _UniformRandomNumberGenerator>
-_LIBCPP_INLINE_VISIBILITY
-_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
- _Distance __n,
- _UniformRandomNumberGenerator& __g,
- forward_iterator_tag) {
- _Distance __unsampled_sz = _VSTD::distance(__first, __last);
- for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
- _Distance __r =
- _VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
- if (__r < __n) {
- *__output_iter++ = *__first;
- --__n;
- }
- }
- return __output_iter;
-}
-
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
- class _UniformRandomNumberGenerator>
-_LIBCPP_INLINE_VISIBILITY
-_SampleIterator __sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
- _Distance __n, _UniformRandomNumberGenerator& __g) {
- typedef typename iterator_traits<_PopulationIterator>::iterator_category
- _PopCategory;
- typedef typename iterator_traits<_PopulationIterator>::difference_type
- _Difference;
- static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value ||
- __is_cpp17_random_access_iterator<_SampleIterator>::value,
- "SampleIterator must meet the requirements of RandomAccessIterator");
- typedef typename common_type<_Distance, _Difference>::type _CommonType;
- _LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
- return _VSTD::__sample(
- __first, __last, __output_iter, _CommonType(__n),
- __g, _PopCategory());
-}
-
-#if _LIBCPP_STD_VER > 14
-template <class _PopulationIterator, class _SampleIterator, class _Distance,
- class _UniformRandomNumberGenerator>
-inline _LIBCPP_INLINE_VISIBILITY
-_SampleIterator sample(_PopulationIterator __first,
- _PopulationIterator __last, _SampleIterator __output_iter,
- _Distance __n, _UniformRandomNumberGenerator&& __g) {
- return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
-}
-#endif // _LIBCPP_STD_VER > 14
-
-template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
- void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _UniformRandomNumberGenerator&& __g)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef uniform_int_distribution<ptrdiff_t> _Dp;
- typedef typename _Dp::param_type _Pp;
- difference_type __d = __last - __first;
- if (__d > 1)
- {
- _Dp __uid;
- for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
- {
- difference_type __i = __uid(__g, _Pp(0, __d));
- if (__i != difference_type(0))
- swap(*__first, *(__first + __i));
- }
- }
-}
-
-#if _LIBCPP_STD_VER > 17
-
-// shift_left, shift_right
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY constexpr
-_ForwardIterator
-shift_left(_ForwardIterator __first, _ForwardIterator __last,
- typename iterator_traits<_ForwardIterator>::difference_type __n)
-{
- if (__n == 0) {
- return __last;
- }
-
- _ForwardIterator __m = __first;
- if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
- if (__n >= __last - __first) {
- return __first;
- }
- __m += __n;
- } else {
- for (; __n > 0; --__n) {
- if (__m == __last) {
- return __first;
- }
- ++__m;
- }
- }
- return _VSTD::move(__m, __last, __first);
-}
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY constexpr
-_ForwardIterator
-shift_right(_ForwardIterator __first, _ForwardIterator __last,
- typename iterator_traits<_ForwardIterator>::difference_type __n)
-{
- if (__n == 0) {
- return __first;
- }
-
- if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
- decltype(__n) __d = __last - __first;
- if (__n >= __d) {
- return __last;
- }
- _ForwardIterator __m = __first + (__d - __n);
- return _VSTD::move_backward(__first, __m, __last);
- } else if constexpr (__is_cpp17_bidirectional_iterator<_ForwardIterator>::value) {
- _ForwardIterator __m = __last;
- for (; __n > 0; --__n) {
- if (__m == __first) {
- return __last;
- }
- --__m;
- }
- return _VSTD::move_backward(__first, __m, __last);
- } else {
- _ForwardIterator __ret = __first;
- for (; __n > 0; --__n) {
- if (__ret == __last) {
- return __last;
- }
- ++__ret;
- }
-
- // We have an __n-element scratch space from __first to __ret.
- // Slide an __n-element window [__trail, __lead) from left to right.
- // We're essentially doing swap_ranges(__first, __ret, __trail, __lead)
- // over and over; but once __lead reaches __last we needn't bother
- // to save the values of elements [__trail, __last).
-
- auto __trail = __first;
- auto __lead = __ret;
- while (__trail != __ret) {
- if (__lead == __last) {
- _VSTD::move(__first, __trail, __ret);
- return __ret;
- }
- ++__trail;
- ++__lead;
- }
-
- _ForwardIterator __mid = __first;
- while (true) {
- if (__lead == __last) {
- __trail = _VSTD::move(__mid, __ret, __trail);
- _VSTD::move(__first, __mid, __trail);
- return __ret;
- }
- swap(*__mid, *__trail);
- ++__mid;
- ++__trail;
- ++__lead;
- if (__mid == __ret) {
- __mid = __first;
- }
- }
- }
-}
-
-#endif // _LIBCPP_STD_VER > 17
-
-// is_partitioned
-
-template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- if (!__pred(*__first))
- break;
- if ( __first == __last )
- return true;
- ++__first;
- for (; __first != __last; ++__first)
- if (__pred(*__first))
- return false;
- return true;
-}
-
-// partition
-
-template <class _Predicate, class _ForwardIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
-{
- while (true)
- {
- if (__first == __last)
- return __first;
- if (!__pred(*__first))
- break;
- ++__first;
- }
- for (_ForwardIterator __p = __first; ++__p != __last;)
- {
- if (__pred(*__p))
- {
- swap(*__first, *__p);
- ++__first;
- }
- }
- return __first;
-}
-
-template <class _Predicate, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator
-__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
- bidirectional_iterator_tag)
-{
- while (true)
- {
- while (true)
- {
- if (__first == __last)
- return __first;
- if (!__pred(*__first))
- break;
- ++__first;
- }
- do
- {
- if (__first == --__last)
- return __first;
- } while (!__pred(*__last));
- swap(*__first, *__last);
- ++__first;
- }
-}
-
-template <class _ForwardIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
-{
- return _VSTD::__partition<typename add_lvalue_reference<_Predicate>::type>
- (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
-}
-
-// partition_copy
-
-template <class _InputIterator, class _OutputIterator1,
- class _OutputIterator2, class _Predicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
-partition_copy(_InputIterator __first, _InputIterator __last,
- _OutputIterator1 __out_true, _OutputIterator2 __out_false,
- _Predicate __pred)
-{
- for (; __first != __last; ++__first)
- {
- if (__pred(*__first))
- {
- *__out_true = *__first;
- ++__out_true;
- }
- else
- {
- *__out_false = *__first;
- ++__out_false;
- }
- }
- return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false);
-}
-
-// partition_point
-
-template<class _ForwardIterator, class _Predicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__pred(*__m))
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
- else
- __len = __l2;
- }
- return __first;
-}
-
-// stable_partition
-
-template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
-_ForwardIterator
-__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
- _Distance __len, _Pair __p, forward_iterator_tag __fit)
-{
- // *__first is known to be false
- // __len >= 1
- if (__len == 1)
- return __first;
- if (__len == 2)
- {
- _ForwardIterator __m = __first;
- if (__pred(*++__m))
- {
- swap(*__first, *__m);
- return __m;
- }
- return __first;
- }
- if (__len <= __p.second)
- { // The buffer is big enough to use
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
- // Move the falses into the temporary buffer, and the trues to the front of the line
- // Update __first to always point to the end of the trues
- value_type* __t = __p.first;
- ::new ((void*)__t) value_type(_VSTD::move(*__first));
- __d.template __incr<value_type>();
- ++__t;
- _ForwardIterator __i = __first;
- while (++__i != __last)
- {
- if (__pred(*__i))
- {
- *__first = _VSTD::move(*__i);
- ++__first;
- }
- else
- {
- ::new ((void*)__t) value_type(_VSTD::move(*__i));
- __d.template __incr<value_type>();
- ++__t;
- }
- }
- // All trues now at start of range, all falses in buffer
- // Move falses back into range, but don't mess up __first which points to first false
- __i = __first;
- for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
- *__i = _VSTD::move(*__t2);
- // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
- return __first;
- }
- // Else not enough buffer, do in place
- // __len >= 3
- _ForwardIterator __m = __first;
- _Distance __len2 = __len / 2; // __len2 >= 2
- _VSTD::advance(__m, __len2);
- // recurse on [__first, __m), *__first know to be false
- // F?????????????????
- // f m l
- typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
- _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
- // TTTFFFFF??????????
- // f ff m l
- // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
- _ForwardIterator __m1 = __m;
- _ForwardIterator __second_false = __last;
- _Distance __len_half = __len - __len2;
- while (__pred(*__m1))
- {
- if (++__m1 == __last)
- goto __second_half_done;
- --__len_half;
- }
- // TTTFFFFFTTTF??????
- // f ff m m1 l
- __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
-__second_half_done:
- // TTTFFFFFTTTTTFFFFF
- // f ff m sf l
- return _VSTD::rotate(__first_false, __m, __second_false);
- // TTTTTTTTFFFFFFFFFF
- // |
-}
-
-struct __return_temporary_buffer
-{
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}
-};
-
-template <class _Predicate, class _ForwardIterator>
-_ForwardIterator
-__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
- forward_iterator_tag)
-{
- const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment
- // Either prove all true and return __first or point to first false
- while (true)
- {
- if (__first == __last)
- return __first;
- if (!__pred(*__first))
- break;
- ++__first;
- }
- // We now have a reduced range [__first, __last)
- // *__first is known to be false
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
- difference_type __len = _VSTD::distance(__first, __last);
- pair<value_type*, ptrdiff_t> __p(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
- if (__len >= __alloc_limit)
- {
- __p = _VSTD::get_temporary_buffer<value_type>(__len);
- __h.reset(__p.first);
- }
- return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
- (__first, __last, __pred, __len, __p, forward_iterator_tag());
-}
-
-template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
-_BidirectionalIterator
-__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
- _Distance __len, _Pair __p, bidirectional_iterator_tag __bit)
-{
- // *__first is known to be false
- // *__last is known to be true
- // __len >= 2
- if (__len == 2)
- {
- swap(*__first, *__last);
- return __last;
- }
- if (__len == 3)
- {
- _BidirectionalIterator __m = __first;
- if (__pred(*++__m))
- {
- swap(*__first, *__m);
- swap(*__m, *__last);
- return __last;
- }
- swap(*__m, *__last);
- swap(*__first, *__m);
- return __m;
- }
- if (__len <= __p.second)
- { // The buffer is big enough to use
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
- // Move the falses into the temporary buffer, and the trues to the front of the line
- // Update __first to always point to the end of the trues
- value_type* __t = __p.first;
- ::new ((void*)__t) value_type(_VSTD::move(*__first));
- __d.template __incr<value_type>();
- ++__t;
- _BidirectionalIterator __i = __first;
- while (++__i != __last)
- {
- if (__pred(*__i))
- {
- *__first = _VSTD::move(*__i);
- ++__first;
- }
- else
- {
- ::new ((void*)__t) value_type(_VSTD::move(*__i));
- __d.template __incr<value_type>();
- ++__t;
- }
- }
- // move *__last, known to be true
- *__first = _VSTD::move(*__i);
- __i = ++__first;
- // All trues now at start of range, all falses in buffer
- // Move falses back into range, but don't mess up __first which points to first false
- for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i)
- *__i = _VSTD::move(*__t2);
- // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
- return __first;
- }
- // Else not enough buffer, do in place
- // __len >= 4
- _BidirectionalIterator __m = __first;
- _Distance __len2 = __len / 2; // __len2 >= 2
- _VSTD::advance(__m, __len2);
- // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false
- // F????????????????T
- // f m l
- _BidirectionalIterator __m1 = __m;
- _BidirectionalIterator __first_false = __first;
- _Distance __len_half = __len2;
- while (!__pred(*--__m1))
- {
- if (__m1 == __first)
- goto __first_half_done;
- --__len_half;
- }
- // F???TFFF?????????T
- // f m1 m l
- typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
- __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
-__first_half_done:
- // TTTFFFFF?????????T
- // f ff m l
- // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
- __m1 = __m;
- _BidirectionalIterator __second_false = __last;
- ++__second_false;
- __len_half = __len - __len2;
- while (__pred(*__m1))
- {
- if (++__m1 == __last)
- goto __second_half_done;
- --__len_half;
- }
- // TTTFFFFFTTTF?????T
- // f ff m m1 l
- __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
-__second_half_done:
- // TTTFFFFFTTTTTFFFFF
- // f ff m sf l
- return _VSTD::rotate(__first_false, __m, __second_false);
- // TTTTTTTTFFFFFFFFFF
- // |
-}
-
-template <class _Predicate, class _BidirectionalIterator>
-_BidirectionalIterator
-__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
- bidirectional_iterator_tag)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- const difference_type __alloc_limit = 4; // might want to make this a function of trivial assignment
- // Either prove all true and return __first or point to first false
- while (true)
- {
- if (__first == __last)
- return __first;
- if (!__pred(*__first))
- break;
- ++__first;
- }
- // __first points to first false, everything prior to __first is already set.
- // Either prove [__first, __last) is all false and return __first, or point __last to last true
- do
- {
- if (__first == --__last)
- return __first;
- } while (!__pred(*__last));
- // We now have a reduced range [__first, __last]
- // *__first is known to be false
- // *__last is known to be true
- // __len >= 2
- difference_type __len = _VSTD::distance(__first, __last) + 1;
- pair<value_type*, ptrdiff_t> __p(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
- if (__len >= __alloc_limit)
- {
- __p = _VSTD::get_temporary_buffer<value_type>(__len);
- __h.reset(__p.first);
- }
- return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
- (__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
-}
-
-template <class _ForwardIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator
-stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
-{
- return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type>
- (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
-}
-
-// is_sorted_until
-
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
- if (__first != __last)
- {
- _ForwardIterator __i = __first;
- while (++__i != __last)
- {
- if (__comp(*__i, *__first))
- return __i;
- __first = __i;
- }
- }
- return __last;
-}
-
-template<class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
-}
-
-// is_sorted
-
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
- return _VSTD::is_sorted_until(__first, __last, __comp) == __last;
-}
-
-template<class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_sorted(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::is_sorted(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
-}
-
-// sort
-
-// stable, 2-3 compares, 0-2 swaps
-
-template <class _Compare, class _ForwardIterator>
-unsigned
-__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c)
-{
- unsigned __r = 0;
- if (!__c(*__y, *__x)) // if x <= y
- {
- if (!__c(*__z, *__y)) // if y <= z
- return __r; // x <= y && y <= z
- // x <= y && y > z
- swap(*__y, *__z); // x <= z && y < z
- __r = 1;
- if (__c(*__y, *__x)) // if x > y
- {
- swap(*__x, *__y); // x < y && y <= z
- __r = 2;
- }
- return __r; // x <= y && y < z
- }
- if (__c(*__z, *__y)) // x > y, if y > z
- {
- swap(*__x, *__z); // x < y && y < z
- __r = 1;
- return __r;
- }
- swap(*__x, *__y); // x > y && y <= z
- __r = 1; // x < y && x <= z
- if (__c(*__z, *__y)) // if y > z
- {
- swap(*__y, *__z); // x <= y && y < z
- __r = 2;
- }
- return __r;
-} // x <= y && y <= z
-
-// stable, 3-6 compares, 0-5 swaps
-
-template <class _Compare, class _ForwardIterator>
-unsigned
-__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
- _ForwardIterator __x4, _Compare __c)
-{
- unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c);
- if (__c(*__x4, *__x3))
- {
- swap(*__x3, *__x4);
- ++__r;
- if (__c(*__x3, *__x2))
- {
- swap(*__x2, *__x3);
- ++__r;
- if (__c(*__x2, *__x1))
- {
- swap(*__x1, *__x2);
- ++__r;
- }
- }
- }
- return __r;
-}
-
-// stable, 4-10 compares, 0-9 swaps
-
-template <class _Compare, class _ForwardIterator>
-_LIBCPP_HIDDEN
-unsigned
-__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
- _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
-{
- unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
- if (__c(*__x5, *__x4))
- {
- swap(*__x4, *__x5);
- ++__r;
- if (__c(*__x4, *__x3))
- {
- swap(*__x3, *__x4);
- ++__r;
- if (__c(*__x3, *__x2))
- {
- swap(*__x2, *__x3);
- ++__r;
- if (__c(*__x2, *__x1))
- {
- swap(*__x1, *__x2);
- ++__r;
- }
- }
- }
- }
- return __r;
-}
-
-// Assumes size > 0
-template <class _Compare, class _BidirectionalIterator>
-void
-__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- _BidirectionalIterator __lm1 = __last;
- for (--__lm1; __first != __lm1; ++__first)
- {
- _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator,
- typename add_lvalue_reference<_Compare>::type>
- (__first, __last, __comp);
- if (__i != __first)
- swap(*__first, *__i);
- }
-}
-
-template <class _Compare, class _BidirectionalIterator>
-void
-__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- if (__first != __last)
- {
- _BidirectionalIterator __i = __first;
- for (++__i; __i != __last; ++__i)
- {
- _BidirectionalIterator __j = __i;
- value_type __t(_VSTD::move(*__j));
- for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
- *__j = _VSTD::move(*__k);
- *__j = _VSTD::move(__t);
- }
- }
-}
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first+2;
- _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
- for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
- {
- if (__comp(*__i, *__j))
- {
- value_type __t(_VSTD::move(*__i));
- _RandomAccessIterator __k = __j;
- __j = __i;
- do
- {
- *__j = _VSTD::move(*__k);
- __j = __k;
- } while (__j != __first && __comp(__t, *--__k));
- *__j = _VSTD::move(__t);
- }
- __j = __i;
- }
-}
-
-template <class _Compare, class _RandomAccessIterator>
-bool
-__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- switch (__last - __first)
- {
- case 0:
- case 1:
- return true;
- case 2:
- if (__comp(*--__last, *__first))
- swap(*__first, *__last);
- return true;
- case 3:
- _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
- return true;
- case 4:
- _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
- return true;
- case 5:
- _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
- return true;
- }
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first+2;
- _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
- const unsigned __limit = 8;
- unsigned __count = 0;
- for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
- {
- if (__comp(*__i, *__j))
- {
- value_type __t(_VSTD::move(*__i));
- _RandomAccessIterator __k = __j;
- __j = __i;
- do
- {
- *__j = _VSTD::move(*__k);
- __j = __k;
- } while (__j != __first && __comp(__t, *--__k));
- *__j = _VSTD::move(__t);
- if (++__count == __limit)
- return ++__i == __last;
- }
- __j = __i;
- }
- return true;
-}
-
-template <class _Compare, class _BidirectionalIterator>
-void
-__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
- typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- if (__first1 != __last1)
- {
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
- value_type* __last2 = __first2;
- ::new ((void*)__last2) value_type(_VSTD::move(*__first1));
- __d.template __incr<value_type>();
- for (++__last2; ++__first1 != __last1; ++__last2)
- {
- value_type* __j2 = __last2;
- value_type* __i2 = __j2;
- if (__comp(*__first1, *--__i2))
- {
- ::new ((void*)__j2) value_type(_VSTD::move(*__i2));
- __d.template __incr<value_type>();
- for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2)
- *__j2 = _VSTD::move(*__i2);
- *__j2 = _VSTD::move(*__first1);
- }
- else
- {
- ::new ((void*)__j2) value_type(_VSTD::move(*__first1));
- __d.template __incr<value_type>();
- }
- }
- __h.release();
- }
-}
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- // _Compare is known to be a reference type
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
- is_trivially_copy_assignable<value_type>::value ? 30 : 6;
- while (true)
- {
- __restart:
- difference_type __len = __last - __first;
- switch (__len)
- {
- case 0:
- case 1:
- return;
- case 2:
- if (__comp(*--__last, *__first))
- swap(*__first, *__last);
- return;
- case 3:
- _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
- return;
- case 4:
- _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
- return;
- case 5:
- _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
- return;
- }
- if (__len <= __limit)
- {
- _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
- return;
- }
- // __len > 5
- _RandomAccessIterator __m = __first;
- _RandomAccessIterator __lm1 = __last;
- --__lm1;
- unsigned __n_swaps;
- {
- difference_type __delta;
- if (__len >= 1000)
- {
- __delta = __len/2;
- __m += __delta;
- __delta /= 2;
- __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp);
- }
- else
- {
- __delta = __len/2;
- __m += __delta;
- __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp);
- }
- }
- // *__m is median
- // partition [__first, __m) < *__m and *__m <= [__m, __last)
- // (this inhibits tossing elements equivalent to __m around unnecessarily)
- _RandomAccessIterator __i = __first;
- _RandomAccessIterator __j = __lm1;
- // j points beyond range to be tested, *__m is known to be <= *__lm1
- // The search going up is known to be guarded but the search coming down isn't.
- // Prime the downward search with a guard.
- if (!__comp(*__i, *__m)) // if *__first == *__m
- {
- // *__first == *__m, *__first doesn't go in first part
- // manually guard downward moving __j against __i
- while (true)
- {
- if (__i == --__j)
- {
- // *__first == *__m, *__m <= all other elements
- // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
- ++__i; // __first + 1
- __j = __last;
- if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
- {
- while (true)
- {
- if (__i == __j)
- return; // [__first, __last) all equivalent elements
- if (__comp(*__first, *__i))
- {
- swap(*__i, *__j);
- ++__n_swaps;
- ++__i;
- break;
- }
- ++__i;
- }
- }
- // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
- if (__i == __j)
- return;
- while (true)
- {
- while (!__comp(*__first, *__i))
- ++__i;
- while (__comp(*__first, *--__j))
- ;
- if (__i >= __j)
- break;
- swap(*__i, *__j);
- ++__n_swaps;
- ++__i;
- }
- // [__first, __i) == *__first and *__first < [__i, __last)
- // The first part is sorted, sort the second part
- // _VSTD::__sort<_Compare>(__i, __last, __comp);
- __first = __i;
- goto __restart;
- }
- if (__comp(*__j, *__m))
- {
- swap(*__i, *__j);
- ++__n_swaps;
- break; // found guard for downward moving __j, now use unguarded partition
- }
- }
- }
- // It is known that *__i < *__m
- ++__i;
- // j points beyond range to be tested, *__m is known to be <= *__lm1
- // if not yet partitioned...
- if (__i < __j)
- {
- // known that *(__i - 1) < *__m
- // known that __i <= __m
- while (true)
- {
- // __m still guards upward moving __i
- while (__comp(*__i, *__m))
- ++__i;
- // It is now known that a guard exists for downward moving __j
- while (!__comp(*--__j, *__m))
- ;
- if (__i > __j)
- break;
- swap(*__i, *__j);
- ++__n_swaps;
- // It is known that __m != __j
- // If __m just moved, follow it
- if (__m == __i)
- __m = __j;
- ++__i;
- }
- }
- // [__first, __i) < *__m and *__m <= [__i, __last)
- if (__i != __m && __comp(*__m, *__i))
- {
- swap(*__i, *__m);
- ++__n_swaps;
- }
- // [__first, __i) < *__i and *__i <= [__i+1, __last)
- // If we were given a perfect partition, see if insertion sort is quick...
- if (__n_swaps == 0)
- {
- bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
- if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp))
- {
- if (__fs)
- return;
- __last = __i;
- continue;
- }
- else
- {
- if (__fs)
- {
- __first = ++__i;
- continue;
- }
- }
- }
- // sort smaller range with recursive call and larger with tail recursion elimination
- if (__i - __first < __last - __i)
- {
- _VSTD::__sort<_Compare>(__first, __i, __comp);
- // _VSTD::__sort<_Compare>(__i+1, __last, __comp);
- __first = ++__i;
- }
- else
- {
- _VSTD::__sort<_Compare>(__i+1, __last, __comp);
- // _VSTD::__sort<_Compare>(__first, __i, __comp);
- __last = __i;
- }
- }
-}
-
-// This forwarder keeps the top call and the recursive calls using the same instantiation, forcing a reference _Compare
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__sort<_Comp_ref>(__first, __last, _Comp_ref(__comp));
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort(_Tp** __first, _Tp** __last)
-{
- _VSTD::sort((uintptr_t*)__first, (uintptr_t*)__last, __less<uintptr_t>());
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last)
-{
- _VSTD::sort(__first.base(), __last.base());
-}
-
-template <class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp)
-{
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
- _VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
-}
-
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
-
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&))
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
-
-_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))
-
-// lower_bound
-
-template <class _Compare, class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__comp(*__m, __value_))
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
- else
- __len = __l2;
- }
- return __first;
-}
-
-template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
- return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
-}
-
-template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::lower_bound(__first, __last, __value_,
- __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
-}
-
-// upper_bound
-
-template <class _Compare, class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__comp(__value_, *__m))
- __len = __l2;
- else
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
- }
- return __first;
-}
-
-template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
- return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
-}
-
-template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
-upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::upper_bound(__first, __last, __value_,
- __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
-}
-
-// equal_range
-
-template <class _Compare, class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
-__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
- while (__len != 0)
- {
- difference_type __l2 = _VSTD::__half_positive(__len);
- _ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
- if (__comp(*__m, __value_))
- {
- __first = ++__m;
- __len -= __l2 + 1;
- }
- else if (__comp(__value_, *__m))
- {
- __last = __m;
- __len = __l2;
- }
- else
- {
- _ForwardIterator __mp1 = __m;
- return pair<_ForwardIterator, _ForwardIterator>
- (
- _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp),
- _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
- );
- }
- }
- return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
-}
-
-template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_ForwardIterator, _ForwardIterator>
-equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp);
-}
-
-template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-pair<_ForwardIterator, _ForwardIterator>
-equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::equal_range(__first, __last, __value_,
- __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
-}
-
-// binary_search
-
-template <class _Compare, class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp);
- return __first != __last && !__comp(__value_, *__first);
-}
-
-template <class _ForwardIterator, class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp);
-}
-
-template <class _ForwardIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
-{
- return _VSTD::binary_search(__first, __last, __value_,
- __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
-}
-
-// merge
-
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- for (; __first1 != __last1; ++__result)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- *__result = *__first1;
- ++__first1;
- }
- }
- return _VSTD::copy(__first2, __last2, __result);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- typedef typename iterator_traits<_InputIterator1>::value_type __v1;
- typedef typename iterator_traits<_InputIterator2>::value_type __v2;
- return _VSTD::merge(__first1, __last1, __first2, __last2, __result, __less<__v1, __v2>());
-}
-
-// inplace_merge
-
-template <class _Compare, class _InputIterator1, class _InputIterator2,
- class _OutputIterator>
-void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
-{
- for (; __first1 != __last1; ++__result)
- {
- if (__first2 == __last2)
- {
- _VSTD::move(__first1, __last1, __result);
- return;
- }
-
- if (__comp(*__first2, *__first1))
- {
- *__result = _VSTD::move(*__first2);
- ++__first2;
- }
- else
- {
- *__result = _VSTD::move(*__first1);
- ++__first1;
- }
- }
- // __first2 through __last2 are already in the right spot.
-}
-
-template <class _Compare, class _BidirectionalIterator>
-void
-__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
- typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
- typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
- if (__len1 <= __len2)
- {
- value_type* __p = __buff;
- for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
- ::new ((void*)__p) value_type(_VSTD::move(*__i));
- _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp);
- }
- else
- {
- value_type* __p = __buff;
- for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p)
- ::new ((void*)__p) value_type(_VSTD::move(*__i));
- typedef reverse_iterator<_BidirectionalIterator> _RBi;
- typedef reverse_iterator<value_type*> _Rv;
- typedef __invert<_Compare> _Inverted;
- _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff),
- _RBi(__middle), _RBi(__first),
- _RBi(__last), _Inverted(__comp));
- }
-}
-
-template <class _Compare, class _BidirectionalIterator>
-void
-__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
- typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
- typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
- while (true)
- {
- // if __middle == __last, we're done
- if (__len2 == 0)
- return;
- if (__len1 <= __buff_size || __len2 <= __buff_size)
- return _VSTD::__buffered_inplace_merge<_Compare>
- (__first, __middle, __last, __comp, __len1, __len2, __buff);
- // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
- for (; true; ++__first, (void) --__len1)
- {
- if (__len1 == 0)
- return;
- if (__comp(*__middle, *__first))
- break;
- }
- // __first < __middle < __last
- // *__first > *__middle
- // partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that
- // all elements in:
- // [__first, __m1) <= [__middle, __m2)
- // [__middle, __m2) < [__m1, __middle)
- // [__m1, __middle) <= [__m2, __last)
- // and __m1 or __m2 is in the middle of its range
- _BidirectionalIterator __m1; // "median" of [__first, __middle)
- _BidirectionalIterator __m2; // "median" of [__middle, __last)
- difference_type __len11; // distance(__first, __m1)
- difference_type __len21; // distance(__middle, __m2)
- // binary search smaller range
- if (__len1 < __len2)
- { // __len >= 1, __len2 >= 2
- __len21 = __len2 / 2;
- __m2 = __middle;
- _VSTD::advance(__m2, __len21);
- __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp);
- __len11 = _VSTD::distance(__first, __m1);
- }
- else
- {
- if (__len1 == 1)
- { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1
- // It is known *__first > *__middle
- swap(*__first, *__middle);
- return;
- }
- // __len1 >= 2, __len2 >= 1
- __len11 = __len1 / 2;
- __m1 = __first;
- _VSTD::advance(__m1, __len11);
- __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp);
- __len21 = _VSTD::distance(__middle, __m2);
- }
- difference_type __len12 = __len1 - __len11; // distance(__m1, __middle)
- difference_type __len22 = __len2 - __len21; // distance(__m2, __last)
- // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
- // swap middle two partitions
- __middle = _VSTD::rotate(__m1, __middle, __m2);
- // __len12 and __len21 now have swapped meanings
- // merge smaller range with recursive call and larger with tail recursion elimination
- if (__len11 + __len21 < __len12 + __len22)
- {
- _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
-// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
- __first = __middle;
- __middle = __m2;
- __len1 = __len12;
- __len2 = __len22;
- }
- else
- {
- _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
-// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
- __last = __middle;
- __middle = __m1;
- __len1 = __len11;
- __len2 = __len21;
- }
- }
-}
-
-template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
- _Compare __comp)
-{
- typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
- typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
- difference_type __len1 = _VSTD::distance(__first, __middle);
- difference_type __len2 = _VSTD::distance(__middle, __last);
- difference_type __buf_size = _VSTD::min(__len1, __len2);
- pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
- unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
- __buf.first, __buf.second);
-}
-
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
-{
- _VSTD::inplace_merge(__first, __middle, __last,
- __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
-}
-
-// stable_sort
-
-template <class _Compare, class _InputIterator1, class _InputIterator2>
-void
-__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
-{
- typedef typename iterator_traits<_InputIterator1>::value_type value_type;
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h(__result, __d);
- for (; true; ++__result)
- {
- if (__first1 == __last1)
- {
- for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>())
- ::new ((void*)__result) value_type(_VSTD::move(*__first2));
- __h.release();
- return;
- }
- if (__first2 == __last2)
- {
- for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>())
- ::new ((void*)__result) value_type(_VSTD::move(*__first1));
- __h.release();
- return;
- }
- if (__comp(*__first2, *__first1))
- {
- ::new ((void*)__result) value_type(_VSTD::move(*__first2));
- __d.template __incr<value_type>();
- ++__first2;
- }
- else
- {
- ::new ((void*)__result) value_type(_VSTD::move(*__first1));
- __d.template __incr<value_type>();
- ++__first1;
- }
- }
-}
-
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-void
-__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2,
- _OutputIterator __result, _Compare __comp)
-{
- for (; __first1 != __last1; ++__result)
- {
- if (__first2 == __last2)
- {
- for (; __first1 != __last1; ++__first1, (void) ++__result)
- *__result = _VSTD::move(*__first1);
- return;
- }
- if (__comp(*__first2, *__first1))
- {
- *__result = _VSTD::move(*__first2);
- ++__first2;
- }
- else
- {
- *__result = _VSTD::move(*__first1);
- ++__first1;
- }
- }
- for (; __first2 != __last2; ++__first2, (void) ++__result)
- *__result = _VSTD::move(*__first2);
-}
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len,
- typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len,
- typename iterator_traits<_RandomAccessIterator>::value_type* __first2)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- switch (__len)
- {
- case 0:
- return;
- case 1:
- ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
- return;
- case 2:
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
- if (__comp(*--__last1, *__first1))
- {
- ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
- __d.template __incr<value_type>();
- ++__first2;
- ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
- }
- else
- {
- ::new ((void*)__first2) value_type(_VSTD::move(*__first1));
- __d.template __incr<value_type>();
- ++__first2;
- ::new ((void*)__first2) value_type(_VSTD::move(*__last1));
- }
- __h2.release();
- return;
- }
- if (__len <= 8)
- {
- _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
- return;
- }
- typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
- _RandomAccessIterator __m = __first1 + __l2;
- _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
- _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
- _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
-}
-
-template <class _Tp>
-struct __stable_sort_switch
-{
- static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;
-};
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len,
- typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- switch (__len)
- {
- case 0:
- case 1:
- return;
- case 2:
- if (__comp(*--__last, *__first))
- swap(*__first, *__last);
- return;
- }
- if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
- {
- _VSTD::__insertion_sort<_Compare>(__first, __last, __comp);
- return;
- }
- typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
- _RandomAccessIterator __m = __first + __l2;
- if (__len <= __buff_size)
- {
- __destruct_n __d(0);
- unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
- _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
- __d.__set(__l2, (value_type*)nullptr);
- _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
- __d.__set(__len, (value_type*)nullptr);
- _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
-// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
-// move_iterator<value_type*>(__buff + __l2),
-// move_iterator<_RandomAccessIterator>(__buff + __l2),
-// move_iterator<_RandomAccessIterator>(__buff + __len),
-// __first, __comp);
- return;
- }
- _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
- _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
- _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __len = __last - __first;
- pair<value_type*, ptrdiff_t> __buf(0, 0);
- unique_ptr<value_type, __return_temporary_buffer> __h;
- if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value))
- {
- __buf = _VSTD::get_temporary_buffer<value_type>(__len);
- __h.reset(__buf.first);
- }
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// is_heap_until
-
-template <class _RandomAccessIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __len = __last - __first;
- difference_type __p = 0;
- difference_type __c = 1;
- _RandomAccessIterator __pp = __first;
- while (__c < __len)
- {
- _RandomAccessIterator __cp = __first + __c;
- if (__comp(*__pp, *__cp))
- return __cp;
- ++__c;
- ++__cp;
- if (__c == __len)
- return __last;
- if (__comp(*__pp, *__cp))
- return __cp;
- ++__p;
- ++__pp;
- __c = 2 * __p + 1;
- }
- return __last;
-}
-
-template<class _RandomAccessIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_RandomAccessIterator
-is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// is_heap
-
-template <class _RandomAccessIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- return _VSTD::is_heap_until(__first, __last, __comp) == __last;
-}
-
-template<class _RandomAccessIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- return _VSTD::is_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// push_heap
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- if (__len > 1)
- {
- __len = (__len - 2) / 2;
- _RandomAccessIterator __ptr = __first + __len;
- if (__comp(*__ptr, *--__last))
- {
- value_type __t(_VSTD::move(*__last));
- do
- {
- *__last = _VSTD::move(*__ptr);
- __last = __ptr;
- if (__len == 0)
- break;
- __len = (__len - 1) / 2;
- __ptr = __first + __len;
- } while (__comp(*__ptr, __t));
- *__last = _VSTD::move(__t);
- }
- }
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// pop_heap
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
- _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len,
- _RandomAccessIterator __start)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- // left-child of __start is at 2 * __start + 1
- // right-child of __start is at 2 * __start + 2
- difference_type __child = __start - __first;
-
- if (__len < 2 || (__len - 2) / 2 < __child)
- return;
-
- __child = 2 * __child + 1;
- _RandomAccessIterator __child_i = __first + __child;
-
- if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
- // right-child exists and is greater than left-child
- ++__child_i;
- ++__child;
- }
-
- // check if we are in heap-order
- if (__comp(*__child_i, *__start))
- // we are, __start is larger than it's largest child
- return;
-
- value_type __top(_VSTD::move(*__start));
- do
- {
- // we are not in heap-order, swap the parent with it's largest child
- *__start = _VSTD::move(*__child_i);
- __start = __child_i;
-
- if ((__len - 2) / 2 < __child)
- break;
-
- // recompute the child based off of the updated parent
- __child = 2 * __child + 1;
- __child_i = __first + __child;
-
- if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
- // right-child exists and is greater than left-child
- ++__child_i;
- ++__child;
- }
-
- // check if we are in heap-order
- } while (!__comp(*__child_i, __top));
- *__start = _VSTD::move(__top);
-}
-
-template <class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename iterator_traits<_RandomAccessIterator>::difference_type __len)
-{
- if (__len > 1)
- {
- swap(*__first, *--__last);
- _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first);
- }
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// make_heap
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- difference_type __n = __last - __first;
- if (__n > 1)
- {
- // start from the first parent, there is no need to consider children
- for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start)
- {
- _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start);
- }
- }
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// sort_heap
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
- _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n);
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
-{
- _VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// partial_sort
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
- _Compare __comp)
-{
- _VSTD::__make_heap<_Compare>(__first, __middle, __comp);
- typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
- for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
- {
- if (__comp(*__i, *__first))
- {
- swap(*__i, *__first);
- _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first);
- }
- }
- _VSTD::__sort_heap<_Compare>(__first, __middle, __comp);
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
- _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
-{
- _VSTD::partial_sort(__first, __middle, __last,
- __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// partial_sort_copy
-
-template <class _Compare, class _InputIterator, class _RandomAccessIterator>
-_RandomAccessIterator
-__partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
-{
- _RandomAccessIterator __r = __result_first;
- if (__r != __result_last)
- {
- for (; __first != __last && __r != __result_last; ++__first, (void) ++__r)
- *__r = *__first;
- _VSTD::__make_heap<_Compare>(__result_first, __r, __comp);
- typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first;
- for (; __first != __last; ++__first)
- if (__comp(*__first, *__result_first))
- {
- *__result_first = *__first;
- _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first);
- }
- _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp);
- }
- return __r;
-}
-
-template <class _InputIterator, class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-_RandomAccessIterator
-partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
-}
-
-template <class _InputIterator, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_RandomAccessIterator
-partial_sort_copy(_InputIterator __first, _InputIterator __last,
- _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
-{
- return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last,
- __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// nth_element
-
-template <class _Compare, class _RandomAccessIterator>
-void
-__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
-{
- // _Compare is known to be a reference type
- typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
- const difference_type __limit = 7;
- while (true)
- {
- __restart:
- if (__nth == __last)
- return;
- difference_type __len = __last - __first;
- switch (__len)
- {
- case 0:
- case 1:
- return;
- case 2:
- if (__comp(*--__last, *__first))
- swap(*__first, *__last);
- return;
- case 3:
- {
- _RandomAccessIterator __m = __first;
- _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp);
- return;
- }
- }
- if (__len <= __limit)
- {
- _VSTD::__selection_sort<_Compare>(__first, __last, __comp);
- return;
- }
- // __len > __limit >= 3
- _RandomAccessIterator __m = __first + __len/2;
- _RandomAccessIterator __lm1 = __last;
- unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp);
- // *__m is median
- // partition [__first, __m) < *__m and *__m <= [__m, __last)
- // (this inhibits tossing elements equivalent to __m around unnecessarily)
- _RandomAccessIterator __i = __first;
- _RandomAccessIterator __j = __lm1;
- // j points beyond range to be tested, *__lm1 is known to be <= *__m
- // The search going up is known to be guarded but the search coming down isn't.
- // Prime the downward search with a guard.
- if (!__comp(*__i, *__m)) // if *__first == *__m
- {
- // *__first == *__m, *__first doesn't go in first part
- // manually guard downward moving __j against __i
- while (true)
- {
- if (__i == --__j)
- {
- // *__first == *__m, *__m <= all other elements
- // Partition instead into [__first, __i) == *__first and *__first < [__i, __last)
- ++__i; // __first + 1
- __j = __last;
- if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
- {
- while (true)
- {
- if (__i == __j)
- return; // [__first, __last) all equivalent elements
- if (__comp(*__first, *__i))
- {
- swap(*__i, *__j);
- ++__n_swaps;
- ++__i;
- break;
- }
- ++__i;
- }
- }
- // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
- if (__i == __j)
- return;
- while (true)
- {
- while (!__comp(*__first, *__i))
- ++__i;
- while (__comp(*__first, *--__j))
- ;
- if (__i >= __j)
- break;
- swap(*__i, *__j);
- ++__n_swaps;
- ++__i;
- }
- // [__first, __i) == *__first and *__first < [__i, __last)
- // The first part is sorted,
- if (__nth < __i)
- return;
- // __nth_element the second part
- // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp);
- __first = __i;
- goto __restart;
- }
- if (__comp(*__j, *__m))
- {
- swap(*__i, *__j);
- ++__n_swaps;
- break; // found guard for downward moving __j, now use unguarded partition
- }
- }
- }
- ++__i;
- // j points beyond range to be tested, *__lm1 is known to be <= *__m
- // if not yet partitioned...
- if (__i < __j)
- {
- // known that *(__i - 1) < *__m
- while (true)
- {
- // __m still guards upward moving __i
- while (__comp(*__i, *__m))
- ++__i;
- // It is now known that a guard exists for downward moving __j
- while (!__comp(*--__j, *__m))
- ;
- if (__i >= __j)
- break;
- swap(*__i, *__j);
- ++__n_swaps;
- // It is known that __m != __j
- // If __m just moved, follow it
- if (__m == __i)
- __m = __j;
- ++__i;
- }
- }
- // [__first, __i) < *__m and *__m <= [__i, __last)
- if (__i != __m && __comp(*__m, *__i))
- {
- swap(*__i, *__m);
- ++__n_swaps;
- }
- // [__first, __i) < *__i and *__i <= [__i+1, __last)
- if (__nth == __i)
- return;
- if (__n_swaps == 0)
- {
- // We were given a perfectly partitioned sequence. Coincidence?
- if (__nth < __i)
- {
- // Check for [__first, __i) already sorted
- __j = __m = __first;
- while (++__j != __i)
- {
- if (__comp(*__j, *__m))
- // not yet sorted, so sort
- goto not_sorted;
- __m = __j;
- }
- // [__first, __i) sorted
- return;
- }
- else
- {
- // Check for [__i, __last) already sorted
- __j = __m = __i;
- while (++__j != __last)
- {
- if (__comp(*__j, *__m))
- // not yet sorted, so sort
- goto not_sorted;
- __m = __j;
- }
- // [__i, __last) sorted
- return;
- }
- }
-not_sorted:
- // __nth_element on range containing __nth
- if (__nth < __i)
- {
- // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp);
- __last = __i;
- }
- else
- {
- // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
- __first = ++__i;
- }
- }
-}
-
-template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
-}
-
-template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)
-{
- _VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
-}
-
-// includes
-
-template <class _Compare, class _InputIterator1, class _InputIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
- _Compare __comp)
-{
- for (; __first2 != __last2; ++__first1)
- {
- if (__first1 == __last1 || __comp(*__first2, *__first1))
- return false;
- if (!__comp(*__first1, *__first2))
- ++__first2;
- }
- return true;
-}
-
-template <class _InputIterator1, class _InputIterator2, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
- _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
-{
- return _VSTD::includes(__first1, __last1, __first2, __last2,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
-}
-
-// set_union
-
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- for (; __first1 != __last1; ++__result)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__first2;
- }
- else
- {
- if (!__comp(*__first1, *__first2))
- ++__first2;
- *__result = *__first1;
- ++__first1;
- }
- }
- return _VSTD::copy(__first2, __last2, __result);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_union(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_union(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
-}
-
-// set_intersection
-
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- while (__first1 != __last1 && __first2 != __last2)
- {
- if (__comp(*__first1, *__first2))
- ++__first1;
- else
- {
- if (!__comp(*__first2, *__first1))
- {
- *__result = *__first1;
- ++__result;
- ++__first1;
- }
- ++__first2;
- }
- }
- return __result;
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
-}
-
-// set_difference
-
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- while (__first1 != __last1)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__result;
- ++__first1;
- }
- else
- {
- if (!__comp(*__first2, *__first1))
- ++__first1;
- ++__first2;
- }
- }
- return __result;
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
-}
-
-// set_symmetric_difference
-
-template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
-__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- while (__first1 != __last1)
- {
- if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
- if (__comp(*__first1, *__first2))
- {
- *__result = *__first1;
- ++__result;
- ++__first1;
- }
- else
- {
- if (__comp(*__first2, *__first1))
- {
- *__result = *__first2;
- ++__result;
- }
- else
- ++__first1;
- ++__first2;
- }
- }
- return _VSTD::copy(__first2, __last2, __result);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
-{
- return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
-}
-
-// lexicographical_compare
-
-template <class _Compare, class _InputIterator1, class _InputIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
-{
- for (; __first2 != __last2; ++__first1, (void) ++__first2)
- {
- if (__first1 == __last1 || __comp(*__first1, *__first2))
- return true;
- if (__comp(*__first2, *__first1))
- return false;
- }
- return false;
-}
-
-template <class _InputIterator1, class _InputIterator2, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
-}
-
-template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
- _InputIterator2 __first2, _InputIterator2 __last2)
-{
- return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2,
- __less<typename iterator_traits<_InputIterator1>::value_type,
- typename iterator_traits<_InputIterator2>::value_type>());
-}
-
-// next_permutation
-
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- _BidirectionalIterator __i = __last;
- if (__first == __last || __first == --__i)
- return false;
- while (true)
- {
- _BidirectionalIterator __ip1 = __i;
- if (__comp(*--__i, *__ip1))
- {
- _BidirectionalIterator __j = __last;
- while (!__comp(*__i, *--__j))
- ;
- swap(*__i, *__j);
- _VSTD::reverse(__ip1, __last);
- return true;
- }
- if (__i == __first)
- {
- _VSTD::reverse(__first, __last);
- return false;
- }
- }
-}
-
-template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp);
-}
-
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
-{
- return _VSTD::next_permutation(__first, __last,
- __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
-}
-
-// prev_permutation
-
-template <class _Compare, class _BidirectionalIterator>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
-__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- _BidirectionalIterator __i = __last;
- if (__first == __last || __first == --__i)
- return false;
- while (true)
- {
- _BidirectionalIterator __ip1 = __i;
- if (__comp(*__ip1, *--__i))
- {
- _BidirectionalIterator __j = __last;
- while (!__comp(*--__j, *__i))
- ;
- swap(*__i, *__j);
- _VSTD::reverse(__ip1, __last);
- return true;
- }
- if (__i == __first)
- {
- _VSTD::reverse(__first, __last);
- return false;
- }
- }
-}
-
-template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
-{
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
- return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp);
-}
-
-template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool
-prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
-{
- return _VSTD::prev_permutation(__first, __last,
- __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
-}
-
-_LIBCPP_END_NAMESPACE_STD
-
_LIBCPP_POP_MACROS
#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
# include <__pstl_algorithm>
#endif
-#endif // _LIBCPP_ALGORITHM
+#endif // _LIBCPP_ALGORITHM
diff --git a/contrib/llvm-project/libcxx/include/any b/contrib/llvm-project/libcxx/include/any
index 968c9769ee36..3a826c4d50b4 100644
--- a/contrib/llvm-project/libcxx/include/any
+++ b/contrib/llvm-project/libcxx/include/any
@@ -80,12 +80,13 @@ namespace std {
*/
-#include <experimental/__config>
#include <__availability>
+#include <__config>
+#include <__utility/forward.h>
+#include <cstdlib>
#include <memory>
-#include <typeinfo>
#include <type_traits>
-#include <cstdlib>
+#include <typeinfo>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/contrib/llvm-project/libcxx/include/array b/contrib/llvm-project/libcxx/include/array
index 9a479f7cd1f7..022172b86ec9 100644
--- a/contrib/llvm-project/libcxx/include/array
+++ b/contrib/llvm-project/libcxx/include/array
@@ -109,25 +109,22 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
*/
#include <__config>
+#include <__debug>
#include <__tuple>
-#include <type_traits>
-#include <utility>
-#include <iterator>
#include <algorithm>
-#include <stdexcept>
#include <cstdlib> // for _LIBCPP_UNREACHABLE
+#include <iterator>
+#include <stdexcept>
+#include <type_traits>
+#include <utility>
#include <version>
-#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
-
-
_LIBCPP_BEGIN_NAMESPACE_STD
-
template <class _Tp, size_t _Size>
struct _LIBCPP_TEMPLATE_VIS array
{
@@ -520,4 +517,4 @@ to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_ARRAY
+#endif // _LIBCPP_ARRAY
diff --git a/contrib/llvm-project/libcxx/include/atomic b/contrib/llvm-project/libcxx/include/atomic
index f17485f5455e..07ea56f65064 100644
--- a/contrib/llvm-project/libcxx/include/atomic
+++ b/contrib/llvm-project/libcxx/include/atomic
@@ -67,7 +67,8 @@ struct atomic
bool is_lock_free() const volatile noexcept;
bool is_lock_free() const noexcept;
- atomic() noexcept = default;
+ atomic() noexcept = default; // until C++20
+ constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); // since C++20
constexpr atomic(T desr) noexcept;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
@@ -201,7 +202,8 @@ struct atomic<T*>
bool is_lock_free() const volatile noexcept;
bool is_lock_free() const noexcept;
- atomic() noexcept = default;
+ atomic() noexcept = default; // until C++20
+ constexpr atomic() noexcept; // since C++20
constexpr atomic(T* desr) noexcept;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
@@ -509,7 +511,8 @@ typedef atomic<uintmax_t> atomic_uintmax_t;
typedef struct atomic_flag
{
- atomic_flag() noexcept = default;
+ atomic_flag() noexcept = default; // until C++20
+ constexpr atomic_flag() noexcept; // since C++20
atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete;
@@ -574,8 +577,8 @@ template <class T>
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <__threading_support>
#include <cstddef>
#include <cstdint>
@@ -669,7 +672,7 @@ static_assert((is_same<underlying_type<memory_order>::type, __memory_order_under
"unexpected underlying type for std::memory_order");
#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) || \
- defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS)
+ defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS)
// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
// the default operator= in an object is not volatile, a byte-by-byte copy
@@ -1017,26 +1020,33 @@ _Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> * __a, _Tp __value, memory
return __c11_atomic_exchange(&__a->__a_value, __value, static_cast<__memory_order_underlying_t>(__order));
}
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR memory_order __to_failure_order(memory_order __order) {
+ // Avoid switch statement to make this a constexpr.
+ return __order == memory_order_release ? memory_order_relaxed:
+ (__order == memory_order_acq_rel ? memory_order_acquire:
+ __order);
+}
+
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
- return __c11_atomic_compare_exchange_strong(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+ return __c11_atomic_compare_exchange_strong(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
}
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_base_impl<_Tp> * __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
- return __c11_atomic_compare_exchange_strong(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+ return __c11_atomic_compare_exchange_strong(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
}
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
- return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+ return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
}
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY
bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_base_impl<_Tp> * __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
- return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+ return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
}
template<class _Tp>
@@ -1127,7 +1137,7 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
# define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE
#endif
# define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
@@ -1141,7 +1151,7 @@ _Tp kill_dependency(_Tp __y) _NOEXCEPT
#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
# define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE
#endif
# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
@@ -1458,7 +1468,7 @@ template<> struct __cxx_is_always_lock_free<bool> { enum { __value = 2 == ATOMIC
template<> struct __cxx_is_always_lock_free<char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
template<> struct __cxx_is_always_lock_free<signed char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
template<> struct __cxx_is_always_lock_free<unsigned char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
template<> struct __cxx_is_always_lock_free<char8_t> { enum { __value = 2 == ATOMIC_CHAR8_T_LOCK_FREE }; };
#endif
template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; };
@@ -1673,24 +1683,23 @@ struct __atomic_base // false
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
+#else
_LIBCPP_INLINE_VISIBILITY
__atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
+#endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
#ifndef _LIBCPP_CXX03_LANG
__atomic_base(const __atomic_base&) = delete;
- __atomic_base& operator=(const __atomic_base&) = delete;
- __atomic_base& operator=(const __atomic_base&) volatile = delete;
#else
private:
_LIBCPP_INLINE_VISIBILITY
__atomic_base(const __atomic_base&);
- _LIBCPP_INLINE_VISIBILITY
- __atomic_base& operator=(const __atomic_base&);
- _LIBCPP_INLINE_VISIBILITY
- __atomic_base& operator=(const __atomic_base&) volatile;
#endif
};
@@ -1706,8 +1715,10 @@ struct __atomic_base<_Tp, true>
: public __atomic_base<_Tp, false>
{
typedef __atomic_base<_Tp, false> __base;
- _LIBCPP_INLINE_VISIBILITY
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
__atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
@@ -1789,8 +1800,15 @@ struct atomic
typedef __atomic_base<_Tp> __base;
typedef _Tp value_type;
typedef value_type difference_type;
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ atomic() = default;
+#else
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT _LIBCPP_DEFAULT
+#endif
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
@@ -1800,6 +1818,9 @@ struct atomic
_LIBCPP_INLINE_VISIBILITY
_Tp operator=(_Tp __d) _NOEXCEPT
{__base::store(__d); return __d;}
+
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
};
// atomic<T*>
@@ -1811,8 +1832,10 @@ struct atomic<_Tp*>
typedef __atomic_base<_Tp*> __base;
typedef _Tp* value_type;
typedef ptrdiff_t difference_type;
+
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT _LIBCPP_DEFAULT
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
@@ -1862,6 +1885,9 @@ struct atomic<_Tp*>
_Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
_LIBCPP_INLINE_VISIBILITY
_Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;}
+
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
};
// atomic_is_lock_free
@@ -1885,7 +1911,7 @@ atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
// atomic_init
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
void
atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
@@ -1893,7 +1919,7 @@ atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NO
}
template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
void
atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
{
@@ -2534,8 +2560,13 @@ typedef struct atomic_flag
void notify_all() _NOEXCEPT
{__cxx_atomic_notify_all(&__a_);}
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ atomic_flag() _NOEXCEPT : __a_(false) {}
+#else
_LIBCPP_INLINE_VISIBILITY
atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT
+#endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
@@ -2728,7 +2759,7 @@ typedef atomic<long> atomic_long;
typedef atomic<unsigned long> atomic_ulong;
typedef atomic<long long> atomic_llong;
typedef atomic<unsigned long long> atomic_ullong;
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef atomic<char8_t> atomic_char8_t;
#endif
typedef atomic<char16_t> atomic_char16_t;
@@ -2801,4 +2832,4 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_ATOMIC
+#endif // _LIBCPP_ATOMIC
diff --git a/contrib/llvm-project/libcxx/include/barrier b/contrib/llvm-project/libcxx/include/barrier
index be213a6895ef..e26dba65329a 100644
--- a/contrib/llvm-project/libcxx/include/barrier
+++ b/contrib/llvm-project/libcxx/include/barrier
@@ -45,8 +45,8 @@ namespace std
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <atomic>
#ifndef _LIBCPP_HAS_NO_TREE_BARRIER
# include <memory>
@@ -107,7 +107,6 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
template<class _CompletionF>
class __barrier_base {
-
ptrdiff_t __expected;
unique_ptr<__barrier_algorithm_base,
void (*)(__barrier_algorithm_base*)> __base;
@@ -146,7 +145,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void wait(arrival_token&& __old_phase) const
{
- auto const __test_fn = [=]() -> bool {
+ auto const __test_fn = [this, __old_phase]() -> bool {
return __phase.load(memory_order_acquire) != __old_phase;
};
__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
@@ -309,11 +308,11 @@ public:
{
__b.wait(_VSTD::move(__phase));
}
- _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait()
{
wait(arrive());
- }
+ }
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_drop()
{
diff --git a/contrib/llvm-project/libcxx/include/bit b/contrib/llvm-project/libcxx/include/bit
index f8c37c3d6bbf..c64e45c5fa30 100644
--- a/contrib/llvm-project/libcxx/include/bit
+++ b/contrib/llvm-project/libcxx/include/bit
@@ -55,11 +55,11 @@ namespace std {
*/
#include <__config>
-#include <__bits>
+#include <__bits> // __libcpp_clz
+#include <__debug>
#include <limits>
#include <type_traits>
#include <version>
-#include <__debug>
#if defined(__IBMCPP__)
#include "__support/ibm/support.h"
@@ -77,49 +77,33 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-using __bitop_unsigned_integer _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
- is_integral<_Tp>::value &&
- is_unsigned<_Tp>::value &&
- _IsNotSame<typename remove_cv<_Tp>::type, bool>::value &&
- _IsNotSame<typename remove_cv<_Tp>::type, signed char>::value &&
- _IsNotSame<typename remove_cv<_Tp>::type, wchar_t>::value &&
- _IsNotSame<typename remove_cv<_Tp>::type, char16_t>::value &&
- _IsNotSame<typename remove_cv<_Tp>::type, char32_t>::value
- >;
-
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__rotl requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
const unsigned int __dig = numeric_limits<_Tp>::digits;
if ((__cnt % __dig) == 0)
return __t;
return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__rotr requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
const unsigned int __dig = numeric_limits<_Tp>::digits;
if ((__cnt % __dig) == 0)
return __t;
return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
}
-
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
int __countr_zero(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__countr_zero requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type");
if (__t == 0)
return numeric_limits<_Tp>::digits;
@@ -132,14 +116,13 @@ int __countr_zero(_Tp __t) _NOEXCEPT
else
{
int __ret = 0;
- int __iter = 0;
const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
- while ((__iter = __libcpp_ctz(static_cast<unsigned long long>(__t))) == __ulldigits)
+ while (static_cast<unsigned long long>(__t) == 0uLL)
{
- __ret += __iter;
+ __ret += __ulldigits;
__t >>= __ulldigits;
}
- return __ret + __iter;
+ return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t));
}
}
@@ -147,7 +130,7 @@ template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
int __countl_zero(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__countl_zero requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
if (__t == 0)
return numeric_limits<_Tp>::digits;
@@ -179,30 +162,27 @@ template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
int __countl_one(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__countl_one requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_one requires an unsigned integer type");
return __t != numeric_limits<_Tp>::max()
? __countl_zero(static_cast<_Tp>(~__t))
: numeric_limits<_Tp>::digits;
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
int __countr_one(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__countr_one requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_one requires an unsigned integer type");
return __t != numeric_limits<_Tp>::max()
? __countr_zero(static_cast<_Tp>(~__t))
: numeric_limits<_Tp>::digits;
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-int
-__popcount(_Tp __t) _NOEXCEPT
+int __popcount(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__libcpp_popcount requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount requires an unsigned integer type");
if (sizeof(_Tp) <= sizeof(unsigned int))
return __libcpp_popcount(static_cast<unsigned int>(__t));
else if (sizeof(_Tp) <= sizeof(unsigned long))
@@ -221,13 +201,12 @@ __popcount(_Tp __t) _NOEXCEPT
}
}
-
// integral log base 2
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
unsigned __bit_log2(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__bit_log2 requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");
return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
}
@@ -235,80 +214,71 @@ template <class _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bool __has_single_bit(_Tp __t) _NOEXCEPT
{
- static_assert(__bitop_unsigned_integer<_Tp>::value, "__has_single_bit requires unsigned");
+ static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type");
return __t != 0 && (((__t & (__t - 1)) == 0));
}
-
#if _LIBCPP_STD_VER > 17
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
rotl(_Tp __t, unsigned int __cnt) noexcept
{
return __rotl(__t, __cnt);
}
-
-// rotr
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
rotr(_Tp __t, unsigned int __cnt) noexcept
{
return __rotr(__t, __cnt);
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int>
countl_zero(_Tp __t) noexcept
{
return __countl_zero(__t);
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int>
countl_one(_Tp __t) noexcept
{
return __countl_one(__t);
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int>
countr_zero(_Tp __t) noexcept
{
return __countr_zero(__t);
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int>
countr_one(_Tp __t) noexcept
{
return __countr_one(__t);
}
-
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int>
popcount(_Tp __t) noexcept
{
return __popcount(__t);
}
-
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, bool>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, bool>
has_single_bit(_Tp __t) noexcept
{
return __has_single_bit(__t);
@@ -316,7 +286,7 @@ has_single_bit(_Tp __t) noexcept
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
bit_floor(_Tp __t) noexcept
{
return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
@@ -324,7 +294,7 @@ bit_floor(_Tp __t) noexcept
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
bit_ceil(_Tp __t) noexcept
{
if (__t < 2) return 1;
@@ -343,7 +313,7 @@ bit_ceil(_Tp __t) noexcept
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+_EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp>
bit_width(_Tp __t) noexcept
{
return __t == 0 ? 0 : __bit_log2(__t) + 1;
diff --git a/contrib/llvm-project/libcxx/include/bitset b/contrib/llvm-project/libcxx/include/bitset
index 00503fe1c141..4b8827e774a3 100644
--- a/contrib/llvm-project/libcxx/include/bitset
+++ b/contrib/llvm-project/libcxx/include/bitset
@@ -114,12 +114,12 @@ template <size_t N> struct hash<std::bitset<N>>;
#include <__config>
#include <__bit_reference>
-#include <cstddef>
+#include <__functional_base>
#include <climits>
-#include <string>
-#include <stdexcept>
+#include <cstddef>
#include <iosfwd>
-#include <__functional_base>
+#include <stdexcept>
+#include <string>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -202,7 +202,7 @@ private:
void __init(unsigned long long __v, false_type) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
void __init(unsigned long long __v, true_type) _NOEXCEPT;
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
unsigned long to_ulong(false_type) const;
_LIBCPP_INLINE_VISIBILITY
unsigned long to_ulong(true_type) const;
@@ -258,7 +258,7 @@ __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT
_VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0));
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <size_t _N_words, size_t _Size>
inline
@@ -775,10 +775,7 @@ bitset<_Size>::bitset(const _CharT* __str,
for (; __i < _Mp; ++__i)
{
_CharT __c = __str[_Mp - 1 - __i];
- if (__c == __zero)
- (*this)[__i] = false;
- else
- (*this)[__i] = true;
+ (*this)[__i] = (__c == __one);
}
_VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
}
@@ -803,10 +800,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
for (; __i < _Mp; ++__i)
{
_CharT __c = __str[__pos + _Mp - 1 - __i];
- if (_Traits::eq(__c, __zero))
- (*this)[__i] = false;
- else
- (*this)[__i] = true;
+ (*this)[__i] = _Traits::eq(__c, __one);
}
_VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
}
@@ -1106,4 +1100,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_BITSET
+#endif // _LIBCPP_BITSET
diff --git a/contrib/llvm-project/libcxx/include/ccomplex b/contrib/llvm-project/libcxx/include/ccomplex
index 0d2e0f5a0f2c..cea450912841 100644
--- a/contrib/llvm-project/libcxx/include/ccomplex
+++ b/contrib/llvm-project/libcxx/include/ccomplex
@@ -25,4 +25,4 @@
// hh 080623 Created
-#endif // _LIBCPP_CCOMPLEX
+#endif // _LIBCPP_CCOMPLEX
diff --git a/contrib/llvm-project/libcxx/include/cctype b/contrib/llvm-project/libcxx/include/cctype
index 55fc9ebc66ce..b078056862a7 100644
--- a/contrib/llvm-project/libcxx/include/cctype
+++ b/contrib/llvm-project/libcxx/include/cctype
@@ -100,21 +100,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#endif
-using ::isalnum;
-using ::isalpha;
-using ::isblank;
-using ::iscntrl;
-using ::isdigit;
-using ::isgraph;
-using ::islower;
-using ::isprint;
-using ::ispunct;
-using ::isspace;
-using ::isupper;
-using ::isxdigit;
-using ::tolower;
-using ::toupper;
+using ::isalnum _LIBCPP_USING_IF_EXISTS;
+using ::isalpha _LIBCPP_USING_IF_EXISTS;
+using ::isblank _LIBCPP_USING_IF_EXISTS;
+using ::iscntrl _LIBCPP_USING_IF_EXISTS;
+using ::isdigit _LIBCPP_USING_IF_EXISTS;
+using ::isgraph _LIBCPP_USING_IF_EXISTS;
+using ::islower _LIBCPP_USING_IF_EXISTS;
+using ::isprint _LIBCPP_USING_IF_EXISTS;
+using ::ispunct _LIBCPP_USING_IF_EXISTS;
+using ::isspace _LIBCPP_USING_IF_EXISTS;
+using ::isupper _LIBCPP_USING_IF_EXISTS;
+using ::isxdigit _LIBCPP_USING_IF_EXISTS;
+using ::tolower _LIBCPP_USING_IF_EXISTS;
+using ::toupper _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CCTYPE
+#endif // _LIBCPP_CCTYPE
diff --git a/contrib/llvm-project/libcxx/include/cerrno b/contrib/llvm-project/libcxx/include/cerrno
index a9268a281f4e..1388d7eac226 100644
--- a/contrib/llvm-project/libcxx/include/cerrno
+++ b/contrib/llvm-project/libcxx/include/cerrno
@@ -29,4 +29,4 @@ Macros:
#pragma GCC system_header
#endif
-#endif // _LIBCPP_CERRNO
+#endif // _LIBCPP_CERRNO
diff --git a/contrib/llvm-project/libcxx/include/cfenv b/contrib/llvm-project/libcxx/include/cfenv
index 6cd91db5a463..05b55ee364f2 100644
--- a/contrib/llvm-project/libcxx/include/cfenv
+++ b/contrib/llvm-project/libcxx/include/cfenv
@@ -61,21 +61,21 @@ int feupdateenv(const fenv_t* envp);
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::fenv_t;
-using ::fexcept_t;
-
-using ::feclearexcept;
-using ::fegetexceptflag;
-using ::feraiseexcept;
-using ::fesetexceptflag;
-using ::fetestexcept;
-using ::fegetround;
-using ::fesetround;
-using ::fegetenv;
-using ::feholdexcept;
-using ::fesetenv;
-using ::feupdateenv;
+using ::fenv_t _LIBCPP_USING_IF_EXISTS;
+using ::fexcept_t _LIBCPP_USING_IF_EXISTS;
+
+using ::feclearexcept _LIBCPP_USING_IF_EXISTS;
+using ::fegetexceptflag _LIBCPP_USING_IF_EXISTS;
+using ::feraiseexcept _LIBCPP_USING_IF_EXISTS;
+using ::fesetexceptflag _LIBCPP_USING_IF_EXISTS;
+using ::fetestexcept _LIBCPP_USING_IF_EXISTS;
+using ::fegetround _LIBCPP_USING_IF_EXISTS;
+using ::fesetround _LIBCPP_USING_IF_EXISTS;
+using ::fegetenv _LIBCPP_USING_IF_EXISTS;
+using ::feholdexcept _LIBCPP_USING_IF_EXISTS;
+using ::fesetenv _LIBCPP_USING_IF_EXISTS;
+using ::feupdateenv _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CFENV
+#endif // _LIBCPP_CFENV
diff --git a/contrib/llvm-project/libcxx/include/cfloat b/contrib/llvm-project/libcxx/include/cfloat
index da22c6f60a2a..77ff5261e3a0 100644
--- a/contrib/llvm-project/libcxx/include/cfloat
+++ b/contrib/llvm-project/libcxx/include/cfloat
@@ -76,4 +76,4 @@ Macros:
#pragma GCC system_header
#endif
-#endif // _LIBCPP_CFLOAT
+#endif // _LIBCPP_CFLOAT
diff --git a/contrib/llvm-project/libcxx/include/charconv b/contrib/llvm-project/libcxx/include/charconv
index 4666c5c51db6..de34112d8eb3 100644
--- a/contrib/llvm-project/libcxx/include/charconv
+++ b/contrib/llvm-project/libcxx/include/charconv
@@ -73,11 +73,13 @@ namespace std {
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <__errc>
+#include <__utility/to_underlying.h>
#include <cmath> // for log2f
#include <cstdint>
+#include <cstdlib> // for _LIBCPP_UNREACHABLE
#include <cstring>
#include <limits>
#include <type_traits>
@@ -108,6 +110,47 @@ enum class _LIBCPP_ENUM_VIS chars_format
general = fixed | scientific
};
+inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
+operator~(chars_format __x) {
+ return chars_format(~_VSTD::__to_underlying(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
+operator&(chars_format __x, chars_format __y) {
+ return chars_format(_VSTD::__to_underlying(__x) &
+ _VSTD::__to_underlying(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
+operator|(chars_format __x, chars_format __y) {
+ return chars_format(_VSTD::__to_underlying(__x) |
+ _VSTD::__to_underlying(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
+operator^(chars_format __x, chars_format __y) {
+ return chars_format(_VSTD::__to_underlying(__x) ^
+ _VSTD::__to_underlying(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
+operator&=(chars_format& __x, chars_format __y) {
+ __x = __x & __y;
+ return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
+operator|=(chars_format& __x, chars_format __y) {
+ __x = __x | __y;
+ return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
+operator^=(chars_format& __x, chars_format __y) {
+ __x = __x ^ __y;
+ return __x;
+}
+
struct _LIBCPP_TYPE_VIS to_chars_result
{
char* ptr;
@@ -289,18 +332,11 @@ __complement(_Tp __x)
}
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY typename make_unsigned<_Tp>::type
-__to_unsigned(_Tp __x)
-{
- return static_cast<typename make_unsigned<_Tp>::type>(__x);
-}
-
-template <typename _Tp>
_LIBCPP_AVAILABILITY_TO_CHARS
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
{
- auto __x = __to_unsigned(__value);
+ auto __x = __to_unsigned_like(__value);
if (__value < 0 && __first != __last)
{
*__first++ = '-';
@@ -348,7 +384,7 @@ inline _LIBCPP_INLINE_VISIBILITY to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
true_type)
{
- auto __x = __to_unsigned(__value);
+ auto __x = __to_unsigned_like(__value);
if (__value < 0 && __first != __last)
{
*__first++ = '-';
@@ -359,32 +395,53 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
}
template <typename _Tp>
+_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) {
+ _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
+
+ unsigned __base_2 = __base * __base;
+ unsigned __base_3 = __base_2 * __base;
+ unsigned __base_4 = __base_2 * __base_2;
+
+ int __r = 0;
+ while (true) {
+ if (__value < __base)
+ return __r + 1;
+ if (__value < __base_2)
+ return __r + 2;
+ if (__value < __base_3)
+ return __r + 3;
+ if (__value < __base_4)
+ return __r + 4;
+
+ __value /= __base_4;
+ __r += 4;
+ }
+
+ _LIBCPP_UNREACHABLE();
+}
+
+template <typename _Tp>
_LIBCPP_AVAILABILITY_TO_CHARS
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
false_type)
{
- if (__base == 10)
- return __to_chars_itoa(__first, __last, __value, false_type());
-
- auto __p = __last;
- while (__p != __first)
- {
- auto __c = __value % __base;
- __value /= __base;
- *--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c];
- if (__value == 0)
- break;
- }
-
- auto __len = __last - __p;
- if (__value != 0 || !__len)
- return {__last, errc::value_too_large};
- else
- {
- _VSTD::memmove(__first, __p, __len);
- return {__first + __len, {}};
- }
+ if (__base == 10)
+ return __to_chars_itoa(__first, __last, __value, false_type());
+
+ ptrdiff_t __cap = __last - __first;
+ int __n = __to_chars_integral_width(__value, __base);
+ if (__n > __cap)
+ return {__last, errc::value_too_large};
+
+ __last = __first + __n;
+ char* __p = __last;
+ do {
+ unsigned __c = __value % __base;
+ __value /= __base;
+ *--__p = "0123456789abcdefghijklmnopqrstuvwxyz"[__c];
+ } while (__value != 0);
+ return {__last, errc(0)};
}
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
@@ -410,7 +467,7 @@ inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
{
using __tl = numeric_limits<_Tp>;
- decltype(__to_unsigned(__value)) __x;
+ decltype(__to_unsigned_like(__value)) __x;
bool __neg = (__first != __last && *__first == '-');
auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
@@ -426,7 +483,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
if (__neg)
{
- if (__x <= __complement(__to_unsigned(__tl::min())))
+ if (__x <= __complement(__to_unsigned_like(__tl::min())))
{
__x = __complement(__x);
_VSTD::memcpy(&__value, &__x, sizeof(__x));
@@ -541,7 +598,7 @@ template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
{
- using __t = decltype(__to_unsigned(__value));
+ using __t = decltype(__to_unsigned_like(__value));
return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
}
@@ -555,13 +612,13 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
return __subject_seq_combinator(
__first, __last, __value,
- [](const char* __p, const char* __last, _Tp& __value,
+ [](const char* __p, const char* __lastx, _Tp& __value,
int __base) -> from_chars_result {
using __tl = numeric_limits<_Tp>;
auto __digits = __tl::digits / log2f(float(__base));
_Tp __a = __in_pattern(*__p++, __base).__val, __b = 0;
- for (int __i = 1; __p != __last; ++__i, ++__p)
+ for (int __i = 1; __p != __lastx; ++__i, ++__p)
{
if (auto __c = __in_pattern(*__p, __base))
{
@@ -579,7 +636,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
break;
}
- if (__p == __last || !__in_pattern(*__p, __base))
+ if (__p == __lastx || !__in_pattern(*__p, __base))
{
if (__tl::max() - __a >= __b)
{
@@ -597,7 +654,7 @@ inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
int __base)
{
- using __t = decltype(__to_unsigned(__value));
+ using __t = decltype(__to_unsigned_like(__value));
return __sign_combinator(__first, __last, __value,
__from_chars_integral<__t>, __base);
}
@@ -617,10 +674,10 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
return __from_chars_integral(__first, __last, __value, __base);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_CHARCONV
+#endif // _LIBCPP_CHARCONV
diff --git a/contrib/llvm-project/libcxx/include/chrono b/contrib/llvm-project/libcxx/include/chrono
index 53e4546010cd..6bdb92912ad0 100644
--- a/contrib/llvm-project/libcxx/include/chrono
+++ b/contrib/llvm-project/libcxx/include/chrono
@@ -823,12 +823,13 @@ constexpr chrono::year operator ""y(unsigned lo
} // std
*/
-#include <__config>
#include <__availability>
+#include <__config>
+#include <compare>
#include <ctime>
-#include <type_traits>
-#include <ratio>
#include <limits>
+#include <ratio>
+#include <type_traits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -1091,7 +1092,7 @@ public:
(__no_overflow<_Period2, period>::type::den == 1 &&
!treat_as_floating_point<_Rep2>::value))
>::type* = nullptr)
- : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
+ : __rep_(chrono::duration_cast<duration>(__d).count()) {}
// observer
@@ -1410,7 +1411,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
time_point<_Clock, _ToDuration>
time_point_cast(const time_point<_Clock, _Duration>& __t)
{
- return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
+ return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
}
#if _LIBCPP_STD_VER > 14
@@ -1926,13 +1927,13 @@ inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
class weekday_indexed {
private:
- _VSTD::chrono::weekday __wd;
+ chrono::weekday __wd;
unsigned char __idx;
public:
weekday_indexed() = default;
- inline constexpr weekday_indexed(const _VSTD::chrono::weekday& __wdval, unsigned __idxval) noexcept
+ inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
: __wd{__wdval}, __idx(__idxval) {}
- inline constexpr _VSTD::chrono::weekday weekday() const noexcept { return __wd; }
+ inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
inline constexpr unsigned index() const noexcept { return __idx; }
inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
};
@@ -1948,11 +1949,11 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex
class weekday_last {
private:
- _VSTD::chrono::weekday __wd;
+ chrono::weekday __wd;
public:
- explicit constexpr weekday_last(const _VSTD::chrono::weekday& __val) noexcept
+ explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
: __wd{__val} {}
- constexpr _VSTD::chrono::weekday weekday() const noexcept { return __wd; }
+ constexpr chrono::weekday weekday() const noexcept { return __wd; }
constexpr bool ok() const noexcept { return __wd.ok(); }
};
@@ -2308,8 +2309,8 @@ inline constexpr
year_month_day
year_month_day::__from_days(days __d) noexcept
{
- static_assert(std::numeric_limits<unsigned>::digits >= 18, "");
- static_assert(std::numeric_limits<int>::digits >= 20 , "");
+ static_assert(numeric_limits<unsigned>::digits >= 18, "");
+ static_assert(numeric_limits<int>::digits >= 20 , "");
const int __z = __d.count() + 719468;
const int __era = (__z >= 0 ? __z : __z - 146096) / 146097;
const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096]
@@ -2325,8 +2326,8 @@ year_month_day::__from_days(days __d) noexcept
// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
inline constexpr days year_month_day::__to_days() const noexcept
{
- static_assert(std::numeric_limits<unsigned>::digits >= 18, "");
- static_assert(std::numeric_limits<int>::digits >= 20 , "");
+ static_assert(numeric_limits<unsigned>::digits >= 18, "");
+ static_assert(numeric_limits<int>::digits >= 20 , "");
const int __yr = static_cast<int>(__y) - (__m <= February);
const unsigned __mth = static_cast<unsigned>(__m);
@@ -2964,4 +2965,4 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_CHRONO
+#endif // _LIBCPP_CHRONO
diff --git a/contrib/llvm-project/libcxx/include/cinttypes b/contrib/llvm-project/libcxx/include/cinttypes
index 55af85cc395d..7ce4a8ad5d80 100644
--- a/contrib/llvm-project/libcxx/include/cinttypes
+++ b/contrib/llvm-project/libcxx/include/cinttypes
@@ -244,14 +244,14 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
_LIBCPP_BEGIN_NAMESPACE_STD
-using::imaxdiv_t;
-using::imaxabs;
-using::imaxdiv;
-using::strtoimax;
-using::strtoumax;
-using::wcstoimax;
-using::wcstoumax;
+using ::imaxdiv_t _LIBCPP_USING_IF_EXISTS;
+using ::imaxabs _LIBCPP_USING_IF_EXISTS;
+using ::imaxdiv _LIBCPP_USING_IF_EXISTS;
+using ::strtoimax _LIBCPP_USING_IF_EXISTS;
+using ::strtoumax _LIBCPP_USING_IF_EXISTS;
+using ::wcstoimax _LIBCPP_USING_IF_EXISTS;
+using ::wcstoumax _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CINTTYPES
+#endif // _LIBCPP_CINTTYPES
diff --git a/contrib/llvm-project/libcxx/include/ciso646 b/contrib/llvm-project/libcxx/include/ciso646
index 172f1676ad9b..c37f6379746b 100644
--- a/contrib/llvm-project/libcxx/include/ciso646
+++ b/contrib/llvm-project/libcxx/include/ciso646
@@ -21,4 +21,4 @@
#pragma GCC system_header
#endif
-#endif // _LIBCPP_CISO646
+#endif // _LIBCPP_CISO646
diff --git a/contrib/llvm-project/libcxx/include/climits b/contrib/llvm-project/libcxx/include/climits
index 43eb2d3f1520..217ec6286e8c 100644
--- a/contrib/llvm-project/libcxx/include/climits
+++ b/contrib/llvm-project/libcxx/include/climits
@@ -44,4 +44,4 @@ Macros:
#pragma GCC system_header
#endif
-#endif // _LIBCPP_CLIMITS
+#endif // _LIBCPP_CLIMITS
diff --git a/contrib/llvm-project/libcxx/include/clocale b/contrib/llvm-project/libcxx/include/clocale
index bff4e92f99ff..8fe91fc5a3a4 100644
--- a/contrib/llvm-project/libcxx/include/clocale
+++ b/contrib/llvm-project/libcxx/include/clocale
@@ -43,12 +43,12 @@ lconv* localeconv();
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::lconv;
+using ::lconv _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
-using ::setlocale;
+using ::setlocale _LIBCPP_USING_IF_EXISTS;
#endif
-using ::localeconv;
+using ::localeconv _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CLOCALE
+#endif // _LIBCPP_CLOCALE
diff --git a/contrib/llvm-project/libcxx/include/cmath b/contrib/llvm-project/libcxx/include/cmath
index 138ae6f99aad..adf83c2b0a7b 100644
--- a/contrib/llvm-project/libcxx/include/cmath
+++ b/contrib/llvm-project/libcxx/include/cmath
@@ -318,217 +318,215 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::signbit;
-using ::fpclassify;
-using ::isfinite;
-using ::isinf;
-using ::isnan;
-using ::isnormal;
-using ::isgreater;
-using ::isgreaterequal;
-using ::isless;
-using ::islessequal;
-using ::islessgreater;
-using ::isunordered;
-using ::isunordered;
-
-using ::float_t;
-using ::double_t;
-
-#ifndef _AIX
-using ::abs;
-#endif
-
-using ::acos;
-using ::acosf;
-using ::asin;
-using ::asinf;
-using ::atan;
-using ::atanf;
-using ::atan2;
-using ::atan2f;
-using ::ceil;
-using ::ceilf;
-using ::cos;
-using ::cosf;
-using ::cosh;
-using ::coshf;
-
-using ::exp;
-using ::expf;
-
-using ::fabs;
-using ::fabsf;
-using ::floor;
-using ::floorf;
-
-using ::fmod;
-using ::fmodf;
-
-using ::frexp;
-using ::frexpf;
-using ::ldexp;
-using ::ldexpf;
-
-using ::log;
-using ::logf;
-
-using ::log10;
-using ::log10f;
-using ::modf;
-using ::modff;
-
-using ::pow;
-using ::powf;
-
-using ::sin;
-using ::sinf;
-using ::sinh;
-using ::sinhf;
-
-using ::sqrt;
-using ::sqrtf;
-using ::tan;
-using ::tanf;
-
-using ::tanh;
-using ::tanhf;
-
-using ::acosh;
-using ::acoshf;
-using ::asinh;
-using ::asinhf;
-using ::atanh;
-using ::atanhf;
-using ::cbrt;
-using ::cbrtf;
-
-using ::copysign;
-using ::copysignf;
-
-using ::erf;
-using ::erff;
-using ::erfc;
-using ::erfcf;
-using ::exp2;
-using ::exp2f;
-using ::expm1;
-using ::expm1f;
-using ::fdim;
-using ::fdimf;
-using ::fmaf;
-using ::fma;
-using ::fmax;
-using ::fmaxf;
-using ::fmin;
-using ::fminf;
-using ::hypot;
-using ::hypotf;
-using ::ilogb;
-using ::ilogbf;
-using ::lgamma;
-using ::lgammaf;
-using ::llrint;
-using ::llrintf;
-using ::llround;
-using ::llroundf;
-using ::log1p;
-using ::log1pf;
-using ::log2;
-using ::log2f;
-using ::logb;
-using ::logbf;
-using ::lrint;
-using ::lrintf;
-using ::lround;
-using ::lroundf;
-
-using ::nan;
-using ::nanf;
-
-using ::nearbyint;
-using ::nearbyintf;
-using ::nextafter;
-using ::nextafterf;
-using ::nexttoward;
-using ::nexttowardf;
-using ::remainder;
-using ::remainderf;
-using ::remquo;
-using ::remquof;
-using ::rint;
-using ::rintf;
-using ::round;
-using ::roundf;
-using ::scalbln;
-using ::scalblnf;
-using ::scalbn;
-using ::scalbnf;
-using ::tgamma;
-using ::tgammaf;
-using ::trunc;
-using ::truncf;
-
-using ::acosl;
-using ::asinl;
-using ::atanl;
-using ::atan2l;
-using ::ceill;
-using ::cosl;
-using ::coshl;
-using ::expl;
-using ::fabsl;
-using ::floorl;
-using ::fmodl;
-using ::frexpl;
-using ::ldexpl;
-using ::logl;
-using ::log10l;
-using ::modfl;
-using ::powl;
-using ::sinl;
-using ::sinhl;
-using ::sqrtl;
-using ::tanl;
-
-using ::tanhl;
-using ::acoshl;
-using ::asinhl;
-using ::atanhl;
-using ::cbrtl;
-
-using ::copysignl;
-
-using ::erfl;
-using ::erfcl;
-using ::exp2l;
-using ::expm1l;
-using ::fdiml;
-using ::fmal;
-using ::fmaxl;
-using ::fminl;
-using ::hypotl;
-using ::ilogbl;
-using ::lgammal;
-using ::llrintl;
-using ::llroundl;
-using ::log1pl;
-using ::log2l;
-using ::logbl;
-using ::lrintl;
-using ::lroundl;
-using ::nanl;
-using ::nearbyintl;
-using ::nextafterl;
-using ::nexttowardl;
-using ::remainderl;
-using ::remquol;
-using ::rintl;
-using ::roundl;
-using ::scalblnl;
-using ::scalbnl;
-using ::tgammal;
-using ::truncl;
+using ::signbit _LIBCPP_USING_IF_EXISTS;
+using ::fpclassify _LIBCPP_USING_IF_EXISTS;
+using ::isfinite _LIBCPP_USING_IF_EXISTS;
+using ::isinf _LIBCPP_USING_IF_EXISTS;
+using ::isnan _LIBCPP_USING_IF_EXISTS;
+using ::isnormal _LIBCPP_USING_IF_EXISTS;
+using ::isgreater _LIBCPP_USING_IF_EXISTS;
+using ::isgreaterequal _LIBCPP_USING_IF_EXISTS;
+using ::isless _LIBCPP_USING_IF_EXISTS;
+using ::islessequal _LIBCPP_USING_IF_EXISTS;
+using ::islessgreater _LIBCPP_USING_IF_EXISTS;
+using ::isunordered _LIBCPP_USING_IF_EXISTS;
+using ::isunordered _LIBCPP_USING_IF_EXISTS;
+
+using ::float_t _LIBCPP_USING_IF_EXISTS;
+using ::double_t _LIBCPP_USING_IF_EXISTS;
+
+using ::abs _LIBCPP_USING_IF_EXISTS;
+
+using ::acos _LIBCPP_USING_IF_EXISTS;
+using ::acosf _LIBCPP_USING_IF_EXISTS;
+using ::asin _LIBCPP_USING_IF_EXISTS;
+using ::asinf _LIBCPP_USING_IF_EXISTS;
+using ::atan _LIBCPP_USING_IF_EXISTS;
+using ::atanf _LIBCPP_USING_IF_EXISTS;
+using ::atan2 _LIBCPP_USING_IF_EXISTS;
+using ::atan2f _LIBCPP_USING_IF_EXISTS;
+using ::ceil _LIBCPP_USING_IF_EXISTS;
+using ::ceilf _LIBCPP_USING_IF_EXISTS;
+using ::cos _LIBCPP_USING_IF_EXISTS;
+using ::cosf _LIBCPP_USING_IF_EXISTS;
+using ::cosh _LIBCPP_USING_IF_EXISTS;
+using ::coshf _LIBCPP_USING_IF_EXISTS;
+
+using ::exp _LIBCPP_USING_IF_EXISTS;
+using ::expf _LIBCPP_USING_IF_EXISTS;
+
+using ::fabs _LIBCPP_USING_IF_EXISTS;
+using ::fabsf _LIBCPP_USING_IF_EXISTS;
+using ::floor _LIBCPP_USING_IF_EXISTS;
+using ::floorf _LIBCPP_USING_IF_EXISTS;
+
+using ::fmod _LIBCPP_USING_IF_EXISTS;
+using ::fmodf _LIBCPP_USING_IF_EXISTS;
+
+using ::frexp _LIBCPP_USING_IF_EXISTS;
+using ::frexpf _LIBCPP_USING_IF_EXISTS;
+using ::ldexp _LIBCPP_USING_IF_EXISTS;
+using ::ldexpf _LIBCPP_USING_IF_EXISTS;
+
+using ::log _LIBCPP_USING_IF_EXISTS;
+using ::logf _LIBCPP_USING_IF_EXISTS;
+
+using ::log10 _LIBCPP_USING_IF_EXISTS;
+using ::log10f _LIBCPP_USING_IF_EXISTS;
+using ::modf _LIBCPP_USING_IF_EXISTS;
+using ::modff _LIBCPP_USING_IF_EXISTS;
+
+using ::pow _LIBCPP_USING_IF_EXISTS;
+using ::powf _LIBCPP_USING_IF_EXISTS;
+
+using ::sin _LIBCPP_USING_IF_EXISTS;
+using ::sinf _LIBCPP_USING_IF_EXISTS;
+using ::sinh _LIBCPP_USING_IF_EXISTS;
+using ::sinhf _LIBCPP_USING_IF_EXISTS;
+
+using ::sqrt _LIBCPP_USING_IF_EXISTS;
+using ::sqrtf _LIBCPP_USING_IF_EXISTS;
+using ::tan _LIBCPP_USING_IF_EXISTS;
+using ::tanf _LIBCPP_USING_IF_EXISTS;
+
+using ::tanh _LIBCPP_USING_IF_EXISTS;
+using ::tanhf _LIBCPP_USING_IF_EXISTS;
+
+using ::acosh _LIBCPP_USING_IF_EXISTS;
+using ::acoshf _LIBCPP_USING_IF_EXISTS;
+using ::asinh _LIBCPP_USING_IF_EXISTS;
+using ::asinhf _LIBCPP_USING_IF_EXISTS;
+using ::atanh _LIBCPP_USING_IF_EXISTS;
+using ::atanhf _LIBCPP_USING_IF_EXISTS;
+using ::cbrt _LIBCPP_USING_IF_EXISTS;
+using ::cbrtf _LIBCPP_USING_IF_EXISTS;
+
+using ::copysign _LIBCPP_USING_IF_EXISTS;
+using ::copysignf _LIBCPP_USING_IF_EXISTS;
+
+using ::erf _LIBCPP_USING_IF_EXISTS;
+using ::erff _LIBCPP_USING_IF_EXISTS;
+using ::erfc _LIBCPP_USING_IF_EXISTS;
+using ::erfcf _LIBCPP_USING_IF_EXISTS;
+using ::exp2 _LIBCPP_USING_IF_EXISTS;
+using ::exp2f _LIBCPP_USING_IF_EXISTS;
+using ::expm1 _LIBCPP_USING_IF_EXISTS;
+using ::expm1f _LIBCPP_USING_IF_EXISTS;
+using ::fdim _LIBCPP_USING_IF_EXISTS;
+using ::fdimf _LIBCPP_USING_IF_EXISTS;
+using ::fmaf _LIBCPP_USING_IF_EXISTS;
+using ::fma _LIBCPP_USING_IF_EXISTS;
+using ::fmax _LIBCPP_USING_IF_EXISTS;
+using ::fmaxf _LIBCPP_USING_IF_EXISTS;
+using ::fmin _LIBCPP_USING_IF_EXISTS;
+using ::fminf _LIBCPP_USING_IF_EXISTS;
+using ::hypot _LIBCPP_USING_IF_EXISTS;
+using ::hypotf _LIBCPP_USING_IF_EXISTS;
+using ::ilogb _LIBCPP_USING_IF_EXISTS;
+using ::ilogbf _LIBCPP_USING_IF_EXISTS;
+using ::lgamma _LIBCPP_USING_IF_EXISTS;
+using ::lgammaf _LIBCPP_USING_IF_EXISTS;
+using ::llrint _LIBCPP_USING_IF_EXISTS;
+using ::llrintf _LIBCPP_USING_IF_EXISTS;
+using ::llround _LIBCPP_USING_IF_EXISTS;
+using ::llroundf _LIBCPP_USING_IF_EXISTS;
+using ::log1p _LIBCPP_USING_IF_EXISTS;
+using ::log1pf _LIBCPP_USING_IF_EXISTS;
+using ::log2 _LIBCPP_USING_IF_EXISTS;
+using ::log2f _LIBCPP_USING_IF_EXISTS;
+using ::logb _LIBCPP_USING_IF_EXISTS;
+using ::logbf _LIBCPP_USING_IF_EXISTS;
+using ::lrint _LIBCPP_USING_IF_EXISTS;
+using ::lrintf _LIBCPP_USING_IF_EXISTS;
+using ::lround _LIBCPP_USING_IF_EXISTS;
+using ::lroundf _LIBCPP_USING_IF_EXISTS;
+
+using ::nan _LIBCPP_USING_IF_EXISTS;
+using ::nanf _LIBCPP_USING_IF_EXISTS;
+
+using ::nearbyint _LIBCPP_USING_IF_EXISTS;
+using ::nearbyintf _LIBCPP_USING_IF_EXISTS;
+using ::nextafter _LIBCPP_USING_IF_EXISTS;
+using ::nextafterf _LIBCPP_USING_IF_EXISTS;
+using ::nexttoward _LIBCPP_USING_IF_EXISTS;
+using ::nexttowardf _LIBCPP_USING_IF_EXISTS;
+using ::remainder _LIBCPP_USING_IF_EXISTS;
+using ::remainderf _LIBCPP_USING_IF_EXISTS;
+using ::remquo _LIBCPP_USING_IF_EXISTS;
+using ::remquof _LIBCPP_USING_IF_EXISTS;
+using ::rint _LIBCPP_USING_IF_EXISTS;
+using ::rintf _LIBCPP_USING_IF_EXISTS;
+using ::round _LIBCPP_USING_IF_EXISTS;
+using ::roundf _LIBCPP_USING_IF_EXISTS;
+using ::scalbln _LIBCPP_USING_IF_EXISTS;
+using ::scalblnf _LIBCPP_USING_IF_EXISTS;
+using ::scalbn _LIBCPP_USING_IF_EXISTS;
+using ::scalbnf _LIBCPP_USING_IF_EXISTS;
+using ::tgamma _LIBCPP_USING_IF_EXISTS;
+using ::tgammaf _LIBCPP_USING_IF_EXISTS;
+using ::trunc _LIBCPP_USING_IF_EXISTS;
+using ::truncf _LIBCPP_USING_IF_EXISTS;
+
+using ::acosl _LIBCPP_USING_IF_EXISTS;
+using ::asinl _LIBCPP_USING_IF_EXISTS;
+using ::atanl _LIBCPP_USING_IF_EXISTS;
+using ::atan2l _LIBCPP_USING_IF_EXISTS;
+using ::ceill _LIBCPP_USING_IF_EXISTS;
+using ::cosl _LIBCPP_USING_IF_EXISTS;
+using ::coshl _LIBCPP_USING_IF_EXISTS;
+using ::expl _LIBCPP_USING_IF_EXISTS;
+using ::fabsl _LIBCPP_USING_IF_EXISTS;
+using ::floorl _LIBCPP_USING_IF_EXISTS;
+using ::fmodl _LIBCPP_USING_IF_EXISTS;
+using ::frexpl _LIBCPP_USING_IF_EXISTS;
+using ::ldexpl _LIBCPP_USING_IF_EXISTS;
+using ::logl _LIBCPP_USING_IF_EXISTS;
+using ::log10l _LIBCPP_USING_IF_EXISTS;
+using ::modfl _LIBCPP_USING_IF_EXISTS;
+using ::powl _LIBCPP_USING_IF_EXISTS;
+using ::sinl _LIBCPP_USING_IF_EXISTS;
+using ::sinhl _LIBCPP_USING_IF_EXISTS;
+using ::sqrtl _LIBCPP_USING_IF_EXISTS;
+using ::tanl _LIBCPP_USING_IF_EXISTS;
+
+using ::tanhl _LIBCPP_USING_IF_EXISTS;
+using ::acoshl _LIBCPP_USING_IF_EXISTS;
+using ::asinhl _LIBCPP_USING_IF_EXISTS;
+using ::atanhl _LIBCPP_USING_IF_EXISTS;
+using ::cbrtl _LIBCPP_USING_IF_EXISTS;
+
+using ::copysignl _LIBCPP_USING_IF_EXISTS;
+
+using ::erfl _LIBCPP_USING_IF_EXISTS;
+using ::erfcl _LIBCPP_USING_IF_EXISTS;
+using ::exp2l _LIBCPP_USING_IF_EXISTS;
+using ::expm1l _LIBCPP_USING_IF_EXISTS;
+using ::fdiml _LIBCPP_USING_IF_EXISTS;
+using ::fmal _LIBCPP_USING_IF_EXISTS;
+using ::fmaxl _LIBCPP_USING_IF_EXISTS;
+using ::fminl _LIBCPP_USING_IF_EXISTS;
+using ::hypotl _LIBCPP_USING_IF_EXISTS;
+using ::ilogbl _LIBCPP_USING_IF_EXISTS;
+using ::lgammal _LIBCPP_USING_IF_EXISTS;
+using ::llrintl _LIBCPP_USING_IF_EXISTS;
+using ::llroundl _LIBCPP_USING_IF_EXISTS;
+using ::log1pl _LIBCPP_USING_IF_EXISTS;
+using ::log2l _LIBCPP_USING_IF_EXISTS;
+using ::logbl _LIBCPP_USING_IF_EXISTS;
+using ::lrintl _LIBCPP_USING_IF_EXISTS;
+using ::lroundl _LIBCPP_USING_IF_EXISTS;
+using ::nanl _LIBCPP_USING_IF_EXISTS;
+using ::nearbyintl _LIBCPP_USING_IF_EXISTS;
+using ::nextafterl _LIBCPP_USING_IF_EXISTS;
+using ::nexttowardl _LIBCPP_USING_IF_EXISTS;
+using ::remainderl _LIBCPP_USING_IF_EXISTS;
+using ::remquol _LIBCPP_USING_IF_EXISTS;
+using ::rintl _LIBCPP_USING_IF_EXISTS;
+using ::roundl _LIBCPP_USING_IF_EXISTS;
+using ::scalblnl _LIBCPP_USING_IF_EXISTS;
+using ::scalbnl _LIBCPP_USING_IF_EXISTS;
+using ::tgammal _LIBCPP_USING_IF_EXISTS;
+using ::truncl _LIBCPP_USING_IF_EXISTS;
#if _LIBCPP_STD_VER > 14
inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
@@ -623,10 +621,10 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
if (__t == 1) return __b;
const _Fp __x = __a + __t * (__b - __a);
- if (__t > 1 == __b > __a)
- return __b < __x ? __x : __b;
+ if ((__t > 1) == (__b > __a))
+ return __b < __x ? __x : __b;
else
- return __x < __b ? __x : __b;
+ return __x < __b ? __x : __b;
}
constexpr float
@@ -674,4 +672,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_CMATH
+#endif // _LIBCPP_CMATH
diff --git a/contrib/llvm-project/libcxx/include/codecvt b/contrib/llvm-project/libcxx/include/codecvt
index 2befa1b0af72..ec7d4a780958 100644
--- a/contrib/llvm-project/libcxx/include/codecvt
+++ b/contrib/llvm-project/libcxx/include/codecvt
@@ -570,4 +570,4 @@ public:
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CODECVT
+#endif // _LIBCPP_CODECVT
diff --git a/contrib/llvm-project/libcxx/include/compare b/contrib/llvm-project/libcxx/include/compare
index 048f4821dd4e..e924bffed165 100644
--- a/contrib/llvm-project/libcxx/include/compare
+++ b/contrib/llvm-project/libcxx/include/compare
@@ -15,15 +15,13 @@
namespace std {
// [cmp.categories], comparison category types
- class weak_equality;
- class strong_equality;
class partial_ordering;
class weak_ordering;
class strong_ordering;
// named comparison functions
- constexpr bool is_eq (weak_equality cmp) noexcept { return cmp == 0; }
- constexpr bool is_neq (weak_equality cmp) noexcept { return cmp != 0; }
+ 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; }
@@ -41,8 +39,6 @@ namespace std {
template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
- template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
- template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
// [cmp.partialord], Class partial_ordering
class partial_ordering {
@@ -126,7 +122,6 @@ namespace std {
#include <__config>
#include <type_traits>
-#include <array>
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#pragma GCC system_header
@@ -134,8 +129,7 @@ namespace std {
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17
-
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR)
// exposition only
enum class _LIBCPP_ENUM_VIS _EqResult : unsigned char {
__zero = 0,
@@ -154,138 +148,21 @@ enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
__unordered = -127
};
+class partial_ordering;
+class weak_ordering;
+class strong_ordering;
+
+template<class _Tp, class... _Args>
+inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...);
+
struct _CmpUnspecifiedParam {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEVAL
_CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
- template<typename _Tp, typename = _VSTD::enable_if_t<!_VSTD::is_same_v<_Tp, int>>>
+ template<class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>>
_CmpUnspecifiedParam(_Tp) = delete;
};
-class weak_equality {
- _LIBCPP_INLINE_VISIBILITY
- constexpr explicit weak_equality(_EqResult __val) noexcept : __value_(__val) {}
-
-public:
- static const weak_equality equivalent;
- static const weak_equality nonequivalent;
-
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept;
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
- _LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept;
-#endif
-
-private:
- _EqResult __value_;
-};
-
-_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::equivalent(_EqResult::__equiv);
-_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::nonequivalent(_EqResult::__nonequiv);
-
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ == _EqResult::__zero;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept {
- return __v.__value_ == _EqResult::__zero;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ != _EqResult::__zero;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept {
- return __v.__value_ != _EqResult::__zero;
-}
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept {
- return __v;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-inline constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept {
- return __v;
-}
-#endif
-
-class strong_equality {
- _LIBCPP_INLINE_VISIBILITY
- explicit constexpr strong_equality(_EqResult __val) noexcept : __value_(__val) {}
-
-public:
- static const strong_equality equal;
- static const strong_equality nonequal;
- static const strong_equality equivalent;
- static const strong_equality nonequivalent;
-
- // conversion
- _LIBCPP_INLINE_VISIBILITY constexpr operator weak_equality() const noexcept {
- return __value_ == _EqResult::__zero ? weak_equality::equivalent
- : weak_equality::nonequivalent;
- }
-
- // comparisons
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept;
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
- _LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept;
-#endif
-private:
- _EqResult __value_;
-};
-
-_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equal(_EqResult::__equal);
-_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequal(_EqResult::__nonequal);
-_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equivalent(_EqResult::__equiv);
-_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequivalent(_EqResult::__nonequiv);
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ == _EqResult::__zero;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept {
- return __v.__value_ == _EqResult::__zero;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ != _EqResult::__zero;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept {
- return __v.__value_ != _EqResult::__zero;
-}
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-_LIBCPP_INLINE_VISIBILITY
-constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept {
- return __v;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept {
- return __v;
-}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-
class partial_ordering {
using _ValueT = signed char;
@@ -311,32 +188,52 @@ public:
static const partial_ordering greater;
static const partial_ordering unordered;
- // conversion
- constexpr operator weak_equality() const noexcept {
- return __value_ == 0 ? weak_equality::equivalent : weak_equality::nonequivalent;
- }
-
// comparisons
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default;
- _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
-#endif
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ == 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ < 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ <= 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ > 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__is_ordered() && __v.__value_ >= 0;
+ }
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 < __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 <= __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 > __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v.__is_ordered() && 0 >= __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+ return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
+ }
private:
_ValueT __value_;
};
@@ -346,68 +243,6 @@ _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::equivalent(_EqRe
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__is_ordered() && __v.__value_ == 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__is_ordered() && __v.__value_ < 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__is_ordered() && __v.__value_ <= 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__is_ordered() && __v.__value_ > 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__is_ordered() && __v.__value_ >= 0;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v.__is_ordered() && 0 == __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v.__is_ordered() && 0 < __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v.__is_ordered() && 0 <= __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v.__is_ordered() && 0 > __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v.__is_ordered() && 0 >= __v.__value_;
-}
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return !__v.__is_ordered() || __v.__value_ != 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return !__v.__is_ordered() || __v.__value_ != 0;
-}
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-_LIBCPP_INLINE_VISIBILITY
-constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
-}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-
class weak_ordering {
using _ValueT = signed char;
@@ -421,13 +256,6 @@ public:
static const weak_ordering equivalent;
static const weak_ordering greater;
- // conversions
- _LIBCPP_INLINE_VISIBILITY
- constexpr operator weak_equality() const noexcept {
- return __value_ == 0 ? weak_equality::equivalent
- : weak_equality::nonequivalent;
- }
-
_LIBCPP_INLINE_VISIBILITY
constexpr operator partial_ordering() const noexcept {
return __value_ == 0 ? partial_ordering::equivalent
@@ -435,25 +263,51 @@ public:
}
// comparisons
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default;
- _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
-#endif
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ == 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ < 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ <= 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ > 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ >= 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 < __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 <= __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 > __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return 0 >= __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
+ return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
+ }
private:
_ValueT __value_;
@@ -462,67 +316,6 @@ private:
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv);
_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ == 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ != 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ < 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ <= 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ > 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ >= 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 == __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 != __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 < __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 <= __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 > __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 >= __v.__value_;
-}
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-_LIBCPP_INLINE_VISIBILITY
-constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
-}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-
class strong_ordering {
using _ValueT = signed char;
@@ -539,18 +332,6 @@ public:
// conversions
_LIBCPP_INLINE_VISIBILITY
- constexpr operator weak_equality() const noexcept {
- return __value_ == 0 ? weak_equality::equivalent
- : weak_equality::nonequivalent;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- constexpr operator strong_equality() const noexcept {
- return __value_ == 0 ? strong_equality::equal
- : strong_equality::nonequal;
- }
-
- _LIBCPP_INLINE_VISIBILITY
constexpr operator partial_ordering() const noexcept {
return __value_ == 0 ? partial_ordering::equivalent
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
@@ -563,25 +344,51 @@ public:
}
// comparisons
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default;
- _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
-#endif
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ == 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ < 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ <= 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ > 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v.__value_ >= 0;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 < __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 <= __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 > __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return 0 >= __v.__value_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
+ return __v;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
+ return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
+ }
private:
_ValueT __value_;
@@ -592,74 +399,8 @@ _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equal(_EqResult::_
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv);
_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ == 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ != 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ < 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ <= 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ > 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ >= 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 == __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 != __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 < __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 <= __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 > __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 >= __v.__value_;
-}
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-_LIBCPP_INLINE_VISIBILITY
-constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
-}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-
// named comparison functions
_LIBCPP_INLINE_VISIBILITY
-constexpr bool is_eq(weak_equality __cmp) noexcept { return __cmp == 0; }
-
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool is_neq(weak_equality __cmp) noexcept { return __cmp != 0; }
-
-_LIBCPP_INLINE_VISIBILITY
constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; }
_LIBCPP_INLINE_VISIBILITY
@@ -675,8 +416,6 @@ namespace __comp_detail {
enum _ClassifyCompCategory : unsigned{
_None,
- _WeakEq,
- _StrongEq,
_PartialOrd,
_WeakOrd,
_StrongOrd,
@@ -686,10 +425,6 @@ enum _ClassifyCompCategory : unsigned{
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
constexpr _ClassifyCompCategory __type_to_enum() noexcept {
- if (is_same_v<_Tp, weak_equality>)
- return _WeakEq;
- if (is_same_v<_Tp, strong_equality>)
- return _StrongEq;
if (is_same_v<_Tp, partial_ordering>)
return _PartialOrd;
if (is_same_v<_Tp, weak_ordering>)
@@ -701,18 +436,12 @@ constexpr _ClassifyCompCategory __type_to_enum() noexcept {
template <size_t _Size>
constexpr _ClassifyCompCategory
-__compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
- array<int, _CCC_Size> __seen = {};
+__compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
+ int __seen[_CCC_Size] = {};
for (auto __type : __types)
++__seen[__type];
if (__seen[_None])
return _None;
- if (__seen[_WeakEq])
- return _WeakEq;
- if (__seen[_StrongEq] && (__seen[_PartialOrd] || __seen[_WeakOrd]))
- return _WeakEq;
- if (__seen[_StrongEq])
- return _StrongEq;
if (__seen[_PartialOrd])
return _PartialOrd;
if (__seen[_WeakOrd])
@@ -720,18 +449,13 @@ __compute_comp_type(array<_ClassifyCompCategory, _Size> __types) {
return _StrongOrd;
}
-template <class ..._Ts>
+template <class ..._Ts, bool _False = false>
constexpr auto __get_comp_type() {
using _CCC = _ClassifyCompCategory;
- constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
- constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
- : __compute_comp_type(__type_kinds);
+ constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};
+ constexpr _CCC _Cat = __compute_comp_type(__type_kinds);
if constexpr (_Cat == _None)
return void();
- else if constexpr (_Cat == _WeakEq)
- return weak_equality::equivalent;
- else if constexpr (_Cat == _StrongEq)
- return strong_equality::equivalent;
else if constexpr (_Cat == _PartialOrd)
return partial_ordering::equivalent;
else if constexpr (_Cat == _WeakOrd)
@@ -739,7 +463,7 @@ constexpr auto __get_comp_type() {
else if constexpr (_Cat == _StrongOrd)
return strong_ordering::equivalent;
else
- static_assert(_Cat != _Cat, "unhandled case");
+ static_assert(_False, "unhandled case");
}
} // namespace __comp_detail
@@ -757,10 +481,8 @@ using common_comparison_category_t = typename common_comparison_category<_Ts...>
template<class _Tp> constexpr strong_ordering strong_order(const _Tp& __lhs, const _Tp& __rhs);
template<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs);
template<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs);
-template<class _Tp> constexpr strong_equality strong_equal(const _Tp& __lhs, const _Tp& __rhs);
-template<class _Tp> constexpr weak_equality weak_equal(const _Tp& __lhs, const _Tp& __rhs);
-#endif // _LIBCPP_STD_VER > 17
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR)
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/complex b/contrib/llvm-project/libcxx/include/complex
index 93b7bb5dd53e..fc52697f7749 100644
--- a/contrib/llvm-project/libcxx/include/complex
+++ b/contrib/llvm-project/libcxx/include/complex
@@ -232,10 +232,10 @@ template<class T> complex<T> tanh (const complex<T>&);
*/
#include <__config>
-#include <type_traits>
-#include <stdexcept>
#include <cmath>
#include <iosfwd>
+#include <stdexcept>
+#include <type_traits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -1490,4 +1490,4 @@ inline namespace literals
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_COMPLEX
+#endif // _LIBCPP_COMPLEX
diff --git a/contrib/llvm-project/libcxx/include/complex.h b/contrib/llvm-project/libcxx/include/complex.h
index b78733b8093a..cdf97ac4671e 100644
--- a/contrib/llvm-project/libcxx/include/complex.h
+++ b/contrib/llvm-project/libcxx/include/complex.h
@@ -31,6 +31,6 @@
#include_next <complex.h>
-#endif // __cplusplus
+#endif // __cplusplus
-#endif // _LIBCPP_COMPLEX_H
+#endif // _LIBCPP_COMPLEX_H
diff --git a/contrib/llvm-project/libcxx/include/concepts b/contrib/llvm-project/libcxx/include/concepts
index cf5f9d63971f..3dec9b527901 100644
--- a/contrib/llvm-project/libcxx/include/concepts
+++ b/contrib/llvm-project/libcxx/include/concepts
@@ -67,9 +67,9 @@ namespace std {
template<class T, class... Args>
concept constructible_from = see below;
- // [concept.defaultconstructible], concept default_constructible
+ // [concept.default.init], concept default_initializable
template<class T>
- concept default_constructible = see below;
+ concept default_initializable = see below;
// [concept.moveconstructible], concept move_constructible
template<class T>
@@ -79,11 +79,6 @@ namespace std {
template<class T>
concept copy_constructible = see below;
- // [concepts.compare], comparison concepts
- // [concept.boolean], concept boolean
- template<class B>
- concept boolean = see below;
-
// [concept.equalitycomparable], concept equality_comparable
template<class T>
concept equality_comparable = see below;
@@ -135,7 +130,10 @@ namespace std {
*/
#include <__config>
+#include <__functional/invoke.h>
+#include <__functional_base>
#include <type_traits>
+#include <utility>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -147,7 +145,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
// [concept.same]
@@ -157,12 +155,298 @@ concept __same_as_impl = _VSTD::_IsSame<_Tp, _Up>::value;
template<class _Tp, class _Up>
concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
+// [concept.derived]
+template<class _Dp, class _Bp>
+concept derived_from =
+ is_base_of_v<_Bp, _Dp> &&
+ is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
+
+// [concept.convertible]
+template<class _From, class _To>
+concept convertible_to =
+ is_convertible_v<_From, _To> &&
+ requires(add_rvalue_reference_t<_From> (&__f)()) {
+ static_cast<_To>(__f());
+ };
+
+// [concept.commonref]
+template<class _Tp, class _Up>
+concept common_reference_with =
+ same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> &&
+ convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&
+ convertible_to<_Up, common_reference_t<_Tp, _Up>>;
+
+// [concept.common]
+template<class _Tp, class _Up>
+concept common_with =
+ same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
+ requires {
+ static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>());
+ static_cast<common_type_t<_Tp, _Up>>(declval<_Up>());
+ } &&
+ common_reference_with<
+ add_lvalue_reference_t<const _Tp>,
+ add_lvalue_reference_t<const _Up>> &&
+ common_reference_with<
+ add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
+ common_reference_t<
+ add_lvalue_reference_t<const _Tp>,
+ add_lvalue_reference_t<const _Up>>>;
+
+// [concepts.arithmetic], arithmetic concepts
+template<class _Tp>
+concept integral = is_integral_v<_Tp>;
+
+template<class _Tp>
+concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;
+
+template<class _Tp>
+concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
+
+template<class _Tp>
+concept floating_point = is_floating_point_v<_Tp>;
+
+// [concept.assignable]
+template<class _Lhs, class _Rhs>
+concept assignable_from =
+ is_lvalue_reference_v<_Lhs> &&
+ common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> &&
+ requires (_Lhs __lhs, _Rhs&& __rhs) {
+ { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;
+ };
+
// [concept.destructible]
template<class _Tp>
-concept destructible = _VSTD::is_nothrow_destructible_v<_Tp>;
+concept destructible = is_nothrow_destructible_v<_Tp>;
+
+// [concept.constructible]
+template<class _Tp, class... _Args>
+concept constructible_from =
+ destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
+
+// [concept.default.init]
+
+template<class _Tp>
+concept __default_initializable = requires { ::new _Tp; };
+
+template<class _Tp>
+concept default_initializable = constructible_from<_Tp> &&
+ requires { _Tp{}; } && __default_initializable<_Tp>;
+
+// [concept.moveconstructible]
+template<class _Tp>
+concept move_constructible =
+ constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
+
+// [concept.copyconstructible]
+template<class _Tp>
+concept copy_constructible =
+ move_constructible<_Tp> &&
+ constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
+ constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
+ constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
+
+// Whether a type is a class type or enumeration type according to the Core wording.
+template<class _Tp>
+concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
+
+// [concept.swappable]
+namespace ranges::__swap {
+ // Deleted to inhibit ADL
+ template<class _Tp>
+ void swap(_Tp&, _Tp&) = delete;
+
+
+ // [1]
+ template<class _Tp, class _Up>
+ concept __unqualified_swappable_with =
+ (__class_or_enum<remove_cvref_t<_Tp>> || __class_or_enum<remove_cvref_t<_Up>>) &&
+ requires(_Tp&& __t, _Up&& __u) {
+ swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u));
+ };
+
+ struct __fn;
+
+ template<class _Tp, class _Up, size_t _Size>
+ concept __swappable_arrays =
+ !__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> &&
+ extent_v<_Tp> == extent_v<_Up> &&
+ requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) {
+ __swap(__t[0], __u[0]);
+ };
+
+ template<class _Tp>
+ concept __exchangeable =
+ !__unqualified_swappable_with<_Tp&, _Tp&> &&
+ move_constructible<_Tp> &&
+ assignable_from<_Tp&, _Tp>;
+
+ struct __fn {
+ // 2.1 `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and...
+ // *The name `swap` is used here unqualified.
+ template<class _Tp, class _Up>
+ requires __unqualified_swappable_with<_Tp, _Up>
+ constexpr void operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
+ {
+ swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u));
+ }
+
+ // 2.2 Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and...
+ template<class _Tp, class _Up, size_t _Size>
+ requires __swappable_arrays<_Tp, _Up, _Size>
+ constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const
+ noexcept(noexcept((*this)(*__t, *__u)))
+ {
+ // TODO(cjdb): replace with `ranges::swap_ranges`.
+ for (size_t __i = 0; __i < _Size; ++__i) {
+ (*this)(__t[__i], __u[__i]);
+ }
+ }
+
+ // 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models...
+ template<__exchangeable _Tp>
+ constexpr void operator()(_Tp& __x, _Tp& __y) const
+ noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>)
+ {
+ __y = _VSTD::exchange(__x, _VSTD::move(__y));
+ }
+ };
+} // namespace ranges::__swap
+
+namespace ranges::inline __cpo {
+ inline constexpr auto swap = __swap::__fn{};
+} // namespace ranges::__cpo
+
+template<class _Tp>
+concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); };
+
+template<class _Tp, class _Up>
+concept swappable_with =
+ common_reference_with<_Tp, _Up> &&
+ requires(_Tp&& __t, _Up&& __u) {
+ ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Tp>(__t));
+ ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Up>(__u));
+ ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u));
+ ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t));
+ };
+
+// [concept.booleantestable]
+template<class _Tp>
+concept __boolean_testable_impl = convertible_to<_Tp, bool>;
+
+template<class _Tp>
+concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) {
+ { !std::forward<_Tp>(__t) } -> __boolean_testable_impl;
+};
+
+// [concept.equalitycomparable]
+template<class _Tp, class _Up>
+concept __weakly_equality_comparable_with =
+ requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
+ { __t == __u } -> __boolean_testable;
+ { __t != __u } -> __boolean_testable;
+ { __u == __t } -> __boolean_testable;
+ { __u != __t } -> __boolean_testable;
+ };
+
+template<class _Tp>
+concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>;
+
+template<class _Tp, class _Up>
+concept equality_comparable_with =
+ equality_comparable<_Tp> && equality_comparable<_Up> &&
+ common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
+ equality_comparable<
+ common_reference_t<
+ __make_const_lvalue_ref<_Tp>,
+ __make_const_lvalue_ref<_Up>>> &&
+ __weakly_equality_comparable_with<_Tp, _Up>;
+
+// [concept.totallyordered]
+
+template<class _Tp, class _Up>
+concept __partially_ordered_with =
+ requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
+ { __t < __u } -> __boolean_testable;
+ { __t > __u } -> __boolean_testable;
+ { __t <= __u } -> __boolean_testable;
+ { __t >= __u } -> __boolean_testable;
+ { __u < __t } -> __boolean_testable;
+ { __u > __t } -> __boolean_testable;
+ { __u <= __t } -> __boolean_testable;
+ { __u >= __t } -> __boolean_testable;
+ };
+
+template<class _Tp>
+concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>;
+
+template<class _Tp, class _Up>
+concept totally_ordered_with =
+ totally_ordered<_Tp> && totally_ordered<_Up> &&
+ equality_comparable_with<_Tp, _Up> &&
+ totally_ordered<
+ common_reference_t<
+ __make_const_lvalue_ref<_Tp>,
+ __make_const_lvalue_ref<_Up>>> &&
+ __partially_ordered_with<_Tp, _Up>;
+
+// [concepts.object]
+template<class _Tp>
+concept movable =
+ is_object_v<_Tp> &&
+ move_constructible<_Tp> &&
+ assignable_from<_Tp&, _Tp> &&
+ swappable<_Tp>;
+
+template<class _Tp>
+concept copyable =
+ copy_constructible<_Tp> &&
+ movable<_Tp> &&
+ assignable_from<_Tp&, _Tp&> &&
+ assignable_from<_Tp&, const _Tp&> &&
+ assignable_from<_Tp&, const _Tp>;
+
+template<class _Tp>
+concept semiregular = copyable<_Tp> && default_initializable<_Tp>;
+
+template<class _Tp>
+concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
+
+// [concept.invocable]
+template<class _Fn, class... _Args>
+concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
+ _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving
+};
+
+// [concept.regular.invocable]
+template<class _Fn, class... _Args>
+concept regular_invocable = invocable<_Fn, _Args...>;
+
+// [concept.predicate]
+template<class _Fn, class... _Args>
+concept predicate =
+ regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;
+
+// [concept.relation]
+template<class _Rp, class _Tp, class _Up>
+concept relation =
+ predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> &&
+ predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>;
+
+// [concept.equiv]
+template<class _Rp, class _Tp, class _Up>
+concept equivalence_relation = relation<_Rp, _Tp, _Up>;
+
+// [concept.strictweakorder]
+template<class _Rp, class _Tp, class _Up>
+concept strict_weak_order = relation<_Rp, _Tp, _Up>;
+
+template<class _Tp, class _Up>
+concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
-#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/condition_variable b/contrib/llvm-project/libcxx/include/condition_variable
index 8c733448e3c5..a33250c67794 100644
--- a/contrib/llvm-project/libcxx/include/condition_variable
+++ b/contrib/llvm-project/libcxx/include/condition_variable
@@ -265,4 +265,4 @@ _LIBCPP_END_NAMESPACE_STD
#endif // !_LIBCPP_HAS_NO_THREADS
-#endif // _LIBCPP_CONDITION_VARIABLE
+#endif // _LIBCPP_CONDITION_VARIABLE
diff --git a/contrib/llvm-project/libcxx/include/csetjmp b/contrib/llvm-project/libcxx/include/csetjmp
index ed94b50d1618..41902f0e4710 100644
--- a/contrib/llvm-project/libcxx/include/csetjmp
+++ b/contrib/llvm-project/libcxx/include/csetjmp
@@ -39,9 +39,9 @@ void longjmp(jmp_buf env, int val);
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::jmp_buf;
-using ::longjmp;
+using ::jmp_buf _LIBCPP_USING_IF_EXISTS;
+using ::longjmp _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSETJMP
+#endif // _LIBCPP_CSETJMP
diff --git a/contrib/llvm-project/libcxx/include/csignal b/contrib/llvm-project/libcxx/include/csignal
index 99abd02de066..3b262b561a40 100644
--- a/contrib/llvm-project/libcxx/include/csignal
+++ b/contrib/llvm-project/libcxx/include/csignal
@@ -48,10 +48,10 @@ int raise(int sig);
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::sig_atomic_t;
-using ::signal;
-using ::raise;
+using ::sig_atomic_t _LIBCPP_USING_IF_EXISTS;
+using ::signal _LIBCPP_USING_IF_EXISTS;
+using ::raise _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSIGNAL
+#endif // _LIBCPP_CSIGNAL
diff --git a/contrib/llvm-project/libcxx/include/cstdarg b/contrib/llvm-project/libcxx/include/cstdarg
index e8147d496a77..352db8b8c1dc 100644
--- a/contrib/llvm-project/libcxx/include/cstdarg
+++ b/contrib/llvm-project/libcxx/include/cstdarg
@@ -40,8 +40,8 @@ Types:
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::va_list;
+using ::va_list _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSTDARG
+#endif // _LIBCPP_CSTDARG
diff --git a/contrib/llvm-project/libcxx/include/cstdbool b/contrib/llvm-project/libcxx/include/cstdbool
index fad47141476c..7708537ca8e0 100644
--- a/contrib/llvm-project/libcxx/include/cstdbool
+++ b/contrib/llvm-project/libcxx/include/cstdbool
@@ -28,4 +28,4 @@ Macros:
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
-#endif // _LIBCPP_CSTDBOOL
+#endif // _LIBCPP_CSTDBOOL
diff --git a/contrib/llvm-project/libcxx/include/cstddef b/contrib/llvm-project/libcxx/include/cstddef
index 2a0bfeb6e15f..1b54e7b2e0dc 100644
--- a/contrib/llvm-project/libcxx/include/cstddef
+++ b/contrib/llvm-project/libcxx/include/cstddef
@@ -46,11 +46,11 @@ Types:
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::ptrdiff_t;
-using ::size_t;
+using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
#if !defined(_LIBCPP_CXX03_LANG)
-using ::max_align_t;
+using ::max_align_t _LIBCPP_USING_IF_EXISTS;
#endif
template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
@@ -59,13 +59,13 @@ template <> struct __libcpp_is_integral<char> { enum { va
template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; };
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
template <> struct __libcpp_is_integral<short> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<int> { enum { value = 1 }; };
@@ -152,10 +152,10 @@ template <class _Integer>
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
template <class _Integer, class = _EnableByteOverload<_Integer> >
- constexpr _Integer
+ _LIBCPP_NODISCARD_EXT constexpr _Integer
to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
}
#endif
-#endif // _LIBCPP_CSTDDEF
+#endif // _LIBCPP_CSTDDEF
diff --git a/contrib/llvm-project/libcxx/include/cstdint b/contrib/llvm-project/libcxx/include/cstdint
index f72fa067373e..aa7c8b5cbf56 100644
--- a/contrib/llvm-project/libcxx/include/cstdint
+++ b/contrib/llvm-project/libcxx/include/cstdint
@@ -149,42 +149,42 @@ Types:
_LIBCPP_BEGIN_NAMESPACE_STD
-using::int8_t;
-using::int16_t;
-using::int32_t;
-using::int64_t;
-
-using::uint8_t;
-using::uint16_t;
-using::uint32_t;
-using::uint64_t;
-
-using::int_least8_t;
-using::int_least16_t;
-using::int_least32_t;
-using::int_least64_t;
-
-using::uint_least8_t;
-using::uint_least16_t;
-using::uint_least32_t;
-using::uint_least64_t;
-
-using::int_fast8_t;
-using::int_fast16_t;
-using::int_fast32_t;
-using::int_fast64_t;
-
-using::uint_fast8_t;
-using::uint_fast16_t;
-using::uint_fast32_t;
-using::uint_fast64_t;
-
-using::intptr_t;
-using::uintptr_t;
-
-using::intmax_t;
-using::uintmax_t;
+using ::int8_t _LIBCPP_USING_IF_EXISTS;
+using ::int16_t _LIBCPP_USING_IF_EXISTS;
+using ::int32_t _LIBCPP_USING_IF_EXISTS;
+using ::int64_t _LIBCPP_USING_IF_EXISTS;
+
+using ::uint8_t _LIBCPP_USING_IF_EXISTS;
+using ::uint16_t _LIBCPP_USING_IF_EXISTS;
+using ::uint32_t _LIBCPP_USING_IF_EXISTS;
+using ::uint64_t _LIBCPP_USING_IF_EXISTS;
+
+using ::int_least8_t _LIBCPP_USING_IF_EXISTS;
+using ::int_least16_t _LIBCPP_USING_IF_EXISTS;
+using ::int_least32_t _LIBCPP_USING_IF_EXISTS;
+using ::int_least64_t _LIBCPP_USING_IF_EXISTS;
+
+using ::uint_least8_t _LIBCPP_USING_IF_EXISTS;
+using ::uint_least16_t _LIBCPP_USING_IF_EXISTS;
+using ::uint_least32_t _LIBCPP_USING_IF_EXISTS;
+using ::uint_least64_t _LIBCPP_USING_IF_EXISTS;
+
+using ::int_fast8_t _LIBCPP_USING_IF_EXISTS;
+using ::int_fast16_t _LIBCPP_USING_IF_EXISTS;
+using ::int_fast32_t _LIBCPP_USING_IF_EXISTS;
+using ::int_fast64_t _LIBCPP_USING_IF_EXISTS;
+
+using ::uint_fast8_t _LIBCPP_USING_IF_EXISTS;
+using ::uint_fast16_t _LIBCPP_USING_IF_EXISTS;
+using ::uint_fast32_t _LIBCPP_USING_IF_EXISTS;
+using ::uint_fast64_t _LIBCPP_USING_IF_EXISTS;
+
+using ::intptr_t _LIBCPP_USING_IF_EXISTS;
+using ::uintptr_t _LIBCPP_USING_IF_EXISTS;
+
+using ::intmax_t _LIBCPP_USING_IF_EXISTS;
+using ::uintmax_t _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSTDINT
+#endif // _LIBCPP_CSTDINT
diff --git a/contrib/llvm-project/libcxx/include/cstdio b/contrib/llvm-project/libcxx/include/cstdio
index d0492a083505..b480f800a7b4 100644
--- a/contrib/llvm-project/libcxx/include/cstdio
+++ b/contrib/llvm-project/libcxx/include/cstdio
@@ -104,72 +104,72 @@ void perror(const char* s);
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::FILE;
-using ::fpos_t;
-using ::size_t;
-
-using ::fclose;
-using ::fflush;
-using ::setbuf;
-using ::setvbuf;
-using ::fprintf;
-using ::fscanf;
-using ::snprintf;
-using ::sprintf;
-using ::sscanf;
-using ::vfprintf;
-using ::vfscanf;
-using ::vsscanf;
-using ::vsnprintf;
-using ::vsprintf;
-using ::fgetc;
-using ::fgets;
-using ::fputc;
-using ::fputs;
-using ::getc;
-using ::putc;
-using ::ungetc;
-using ::fread;
-using ::fwrite;
+using ::FILE _LIBCPP_USING_IF_EXISTS;
+using ::fpos_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+
+using ::fclose _LIBCPP_USING_IF_EXISTS;
+using ::fflush _LIBCPP_USING_IF_EXISTS;
+using ::setbuf _LIBCPP_USING_IF_EXISTS;
+using ::setvbuf _LIBCPP_USING_IF_EXISTS;
+using ::fprintf _LIBCPP_USING_IF_EXISTS;
+using ::fscanf _LIBCPP_USING_IF_EXISTS;
+using ::snprintf _LIBCPP_USING_IF_EXISTS;
+using ::sprintf _LIBCPP_USING_IF_EXISTS;
+using ::sscanf _LIBCPP_USING_IF_EXISTS;
+using ::vfprintf _LIBCPP_USING_IF_EXISTS;
+using ::vfscanf _LIBCPP_USING_IF_EXISTS;
+using ::vsscanf _LIBCPP_USING_IF_EXISTS;
+using ::vsnprintf _LIBCPP_USING_IF_EXISTS;
+using ::vsprintf _LIBCPP_USING_IF_EXISTS;
+using ::fgetc _LIBCPP_USING_IF_EXISTS;
+using ::fgets _LIBCPP_USING_IF_EXISTS;
+using ::fputc _LIBCPP_USING_IF_EXISTS;
+using ::fputs _LIBCPP_USING_IF_EXISTS;
+using ::getc _LIBCPP_USING_IF_EXISTS;
+using ::putc _LIBCPP_USING_IF_EXISTS;
+using ::ungetc _LIBCPP_USING_IF_EXISTS;
+using ::fread _LIBCPP_USING_IF_EXISTS;
+using ::fwrite _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
-using ::fgetpos;
+using ::fgetpos _LIBCPP_USING_IF_EXISTS;
#endif
-using ::fseek;
+using ::fseek _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
-using ::fsetpos;
+using ::fsetpos _LIBCPP_USING_IF_EXISTS;
#endif
-using ::ftell;
-using ::rewind;
-using ::clearerr;
-using ::feof;
-using ::ferror;
-using ::perror;
+using ::ftell _LIBCPP_USING_IF_EXISTS;
+using ::rewind _LIBCPP_USING_IF_EXISTS;
+using ::clearerr _LIBCPP_USING_IF_EXISTS;
+using ::feof _LIBCPP_USING_IF_EXISTS;
+using ::ferror _LIBCPP_USING_IF_EXISTS;
+using ::perror _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
-using ::fopen;
-using ::freopen;
-using ::remove;
-using ::rename;
-using ::tmpfile;
-using ::tmpnam;
+using ::fopen _LIBCPP_USING_IF_EXISTS;
+using ::freopen _LIBCPP_USING_IF_EXISTS;
+using ::remove _LIBCPP_USING_IF_EXISTS;
+using ::rename _LIBCPP_USING_IF_EXISTS;
+using ::tmpfile _LIBCPP_USING_IF_EXISTS;
+using ::tmpnam _LIBCPP_USING_IF_EXISTS;
#endif
#ifndef _LIBCPP_HAS_NO_STDIN
-using ::getchar;
+using ::getchar _LIBCPP_USING_IF_EXISTS;
#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
-using ::gets;
+using ::gets _LIBCPP_USING_IF_EXISTS;
#endif
-using ::scanf;
-using ::vscanf;
+using ::scanf _LIBCPP_USING_IF_EXISTS;
+using ::vscanf _LIBCPP_USING_IF_EXISTS;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
-using ::printf;
-using ::putchar;
-using ::puts;
-using ::vprintf;
+using ::printf _LIBCPP_USING_IF_EXISTS;
+using ::putchar _LIBCPP_USING_IF_EXISTS;
+using ::puts _LIBCPP_USING_IF_EXISTS;
+using ::vprintf _LIBCPP_USING_IF_EXISTS;
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSTDIO
+#endif // _LIBCPP_CSTDIO
diff --git a/contrib/llvm-project/libcxx/include/cstdlib b/contrib/llvm-project/libcxx/include/cstdlib
index 675a12d9e04b..ced0321aa8e5 100644
--- a/contrib/llvm-project/libcxx/include/cstdlib
+++ b/contrib/llvm-project/libcxx/include/cstdlib
@@ -96,68 +96,68 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::size_t;
-using ::div_t;
-using ::ldiv_t;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::div_t _LIBCPP_USING_IF_EXISTS;
+using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::lldiv_t;
+using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::atof;
-using ::atoi;
-using ::atol;
+using ::atof _LIBCPP_USING_IF_EXISTS;
+using ::atoi _LIBCPP_USING_IF_EXISTS;
+using ::atol _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::atoll;
+using ::atoll _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::strtod;
-using ::strtof;
-using ::strtold;
-using ::strtol;
+using ::strtod _LIBCPP_USING_IF_EXISTS;
+using ::strtof _LIBCPP_USING_IF_EXISTS;
+using ::strtold _LIBCPP_USING_IF_EXISTS;
+using ::strtol _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoll;
+using ::strtoll _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoul;
+using ::strtoul _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::strtoull;
+using ::strtoull _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::rand;
-using ::srand;
-using ::calloc;
-using ::free;
-using ::malloc;
-using ::realloc;
-using ::abort;
-using ::atexit;
-using ::exit;
-using ::_Exit;
+using ::rand _LIBCPP_USING_IF_EXISTS;
+using ::srand _LIBCPP_USING_IF_EXISTS;
+using ::calloc _LIBCPP_USING_IF_EXISTS;
+using ::free _LIBCPP_USING_IF_EXISTS;
+using ::malloc _LIBCPP_USING_IF_EXISTS;
+using ::realloc _LIBCPP_USING_IF_EXISTS;
+using ::abort _LIBCPP_USING_IF_EXISTS;
+using ::atexit _LIBCPP_USING_IF_EXISTS;
+using ::exit _LIBCPP_USING_IF_EXISTS;
+using ::_Exit _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_WINDOWS_STORE_APP
-using ::getenv;
-using ::system;
+using ::getenv _LIBCPP_USING_IF_EXISTS;
+using ::system _LIBCPP_USING_IF_EXISTS;
#endif
-using ::bsearch;
-using ::qsort;
-using ::abs;
-using ::labs;
+using ::bsearch _LIBCPP_USING_IF_EXISTS;
+using ::qsort _LIBCPP_USING_IF_EXISTS;
+using ::abs _LIBCPP_USING_IF_EXISTS;
+using ::labs _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::llabs;
+using ::llabs _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::div;
-using ::ldiv;
+using ::div _LIBCPP_USING_IF_EXISTS;
+using ::ldiv _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::lldiv;
+using ::lldiv _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::mblen;
-using ::mbtowc;
-using ::wctomb;
-using ::mbstowcs;
-using ::wcstombs;
+using ::mblen _LIBCPP_USING_IF_EXISTS;
+using ::mbtowc _LIBCPP_USING_IF_EXISTS;
+using ::wctomb _LIBCPP_USING_IF_EXISTS;
+using ::mbstowcs _LIBCPP_USING_IF_EXISTS;
+using ::wcstombs _LIBCPP_USING_IF_EXISTS;
#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
-using ::at_quick_exit;
-using ::quick_exit;
+using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
+using ::quick_exit _LIBCPP_USING_IF_EXISTS;
#endif
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
-using ::aligned_alloc;
+using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSTDLIB
+#endif // _LIBCPP_CSTDLIB
diff --git a/contrib/llvm-project/libcxx/include/cstring b/contrib/llvm-project/libcxx/include/cstring
index 8bc96a023302..34449ab3330b 100644
--- a/contrib/llvm-project/libcxx/include/cstring
+++ b/contrib/llvm-project/libcxx/include/cstring
@@ -65,32 +65,32 @@ size_t strlen(const char* s);
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::size_t;
-using ::memcpy;
-using ::memmove;
-using ::strcpy;
-using ::strncpy;
-using ::strcat;
-using ::strncat;
-using ::memcmp;
-using ::strcmp;
-using ::strncmp;
-using ::strcoll;
-using ::strxfrm;
-using ::memchr;
-using ::strchr;
-using ::strcspn;
-using ::strpbrk;
-using ::strrchr;
-using ::strspn;
-using ::strstr;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::memcpy _LIBCPP_USING_IF_EXISTS;
+using ::memmove _LIBCPP_USING_IF_EXISTS;
+using ::strcpy _LIBCPP_USING_IF_EXISTS;
+using ::strncpy _LIBCPP_USING_IF_EXISTS;
+using ::strcat _LIBCPP_USING_IF_EXISTS;
+using ::strncat _LIBCPP_USING_IF_EXISTS;
+using ::memcmp _LIBCPP_USING_IF_EXISTS;
+using ::strcmp _LIBCPP_USING_IF_EXISTS;
+using ::strncmp _LIBCPP_USING_IF_EXISTS;
+using ::strcoll _LIBCPP_USING_IF_EXISTS;
+using ::strxfrm _LIBCPP_USING_IF_EXISTS;
+using ::memchr _LIBCPP_USING_IF_EXISTS;
+using ::strchr _LIBCPP_USING_IF_EXISTS;
+using ::strcspn _LIBCPP_USING_IF_EXISTS;
+using ::strpbrk _LIBCPP_USING_IF_EXISTS;
+using ::strrchr _LIBCPP_USING_IF_EXISTS;
+using ::strspn _LIBCPP_USING_IF_EXISTS;
+using ::strstr _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
-using ::strtok;
+using ::strtok _LIBCPP_USING_IF_EXISTS;
#endif
-using ::memset;
-using ::strerror;
-using ::strlen;
+using ::memset _LIBCPP_USING_IF_EXISTS;
+using ::strerror _LIBCPP_USING_IF_EXISTS;
+using ::strlen _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CSTRING
+#endif // _LIBCPP_CSTRING
diff --git a/contrib/llvm-project/libcxx/include/ctgmath b/contrib/llvm-project/libcxx/include/ctgmath
index ba1eeeac9f70..41f7f0a172ea 100644
--- a/contrib/llvm-project/libcxx/include/ctgmath
+++ b/contrib/llvm-project/libcxx/include/ctgmath
@@ -25,4 +25,4 @@
#pragma GCC system_header
#endif
-#endif // _LIBCPP_CTGMATH
+#endif // _LIBCPP_CTGMATH
diff --git a/contrib/llvm-project/libcxx/include/ctime b/contrib/llvm-project/libcxx/include/ctime
index b0e6c65af5d5..8b2efd7449ca 100644
--- a/contrib/llvm-project/libcxx/include/ctime
+++ b/contrib/llvm-project/libcxx/include/ctime
@@ -68,28 +68,28 @@ int timespec_get( struct timespec *ts, int base); // C++17
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::clock_t;
-using ::size_t;
-using ::time_t;
-using ::tm;
+using ::clock_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::time_t _LIBCPP_USING_IF_EXISTS;
+using ::tm _LIBCPP_USING_IF_EXISTS;
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
-using ::timespec;
+using ::timespec _LIBCPP_USING_IF_EXISTS;
#endif
-using ::clock;
-using ::difftime;
-using ::mktime;
-using ::time;
+using ::clock _LIBCPP_USING_IF_EXISTS;
+using ::difftime _LIBCPP_USING_IF_EXISTS;
+using ::mktime _LIBCPP_USING_IF_EXISTS;
+using ::time _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
-using ::asctime;
-using ::ctime;
-using ::gmtime;
-using ::localtime;
+using ::asctime _LIBCPP_USING_IF_EXISTS;
+using ::ctime _LIBCPP_USING_IF_EXISTS;
+using ::gmtime _LIBCPP_USING_IF_EXISTS;
+using ::localtime _LIBCPP_USING_IF_EXISTS;
#endif
-using ::strftime;
+using ::strftime _LIBCPP_USING_IF_EXISTS;
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
-using ::timespec_get;
+using ::timespec_get _LIBCPP_USING_IF_EXISTS;
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CTIME
+#endif // _LIBCPP_CTIME
diff --git a/contrib/llvm-project/libcxx/include/ctype.h b/contrib/llvm-project/libcxx/include/ctype.h
index dcc7935a29a0..967b6be1e390 100644
--- a/contrib/llvm-project/libcxx/include/ctype.h
+++ b/contrib/llvm-project/libcxx/include/ctype.h
@@ -56,4 +56,4 @@ int toupper(int c);
#endif
-#endif // _LIBCPP_CTYPE_H
+#endif // _LIBCPP_CTYPE_H
diff --git a/contrib/llvm-project/libcxx/include/cwchar b/contrib/llvm-project/libcxx/include/cwchar
index 451c621f9c06..f39046f0a9c2 100644
--- a/contrib/llvm-project/libcxx/include/cwchar
+++ b/contrib/llvm-project/libcxx/include/cwchar
@@ -112,81 +112,81 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::mbstate_t;
-using ::size_t;
-using ::tm;
-using ::wint_t;
-using ::FILE;
-using ::fwprintf;
-using ::fwscanf;
-using ::swprintf;
-using ::vfwprintf;
-using ::vswprintf;
-using ::swscanf;
-using ::vfwscanf;
-using ::vswscanf;
-using ::fgetwc;
-using ::fgetws;
-using ::fputwc;
-using ::fputws;
-using ::fwide;
-using ::getwc;
-using ::putwc;
-using ::ungetwc;
-using ::wcstod;
-using ::wcstof;
-using ::wcstold;
-using ::wcstol;
+using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::tm _LIBCPP_USING_IF_EXISTS;
+using ::wint_t _LIBCPP_USING_IF_EXISTS;
+using ::FILE _LIBCPP_USING_IF_EXISTS;
+using ::fwprintf _LIBCPP_USING_IF_EXISTS;
+using ::fwscanf _LIBCPP_USING_IF_EXISTS;
+using ::swprintf _LIBCPP_USING_IF_EXISTS;
+using ::vfwprintf _LIBCPP_USING_IF_EXISTS;
+using ::vswprintf _LIBCPP_USING_IF_EXISTS;
+using ::swscanf _LIBCPP_USING_IF_EXISTS;
+using ::vfwscanf _LIBCPP_USING_IF_EXISTS;
+using ::vswscanf _LIBCPP_USING_IF_EXISTS;
+using ::fgetwc _LIBCPP_USING_IF_EXISTS;
+using ::fgetws _LIBCPP_USING_IF_EXISTS;
+using ::fputwc _LIBCPP_USING_IF_EXISTS;
+using ::fputws _LIBCPP_USING_IF_EXISTS;
+using ::fwide _LIBCPP_USING_IF_EXISTS;
+using ::getwc _LIBCPP_USING_IF_EXISTS;
+using ::putwc _LIBCPP_USING_IF_EXISTS;
+using ::ungetwc _LIBCPP_USING_IF_EXISTS;
+using ::wcstod _LIBCPP_USING_IF_EXISTS;
+using ::wcstof _LIBCPP_USING_IF_EXISTS;
+using ::wcstold _LIBCPP_USING_IF_EXISTS;
+using ::wcstol _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::wcstoll;
+using ::wcstoll _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::wcstoul;
+using ::wcstoul _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
-using ::wcstoull;
+using ::wcstoull _LIBCPP_USING_IF_EXISTS;
#endif // _LIBCPP_HAS_NO_LONG_LONG
-using ::wcscpy;
-using ::wcsncpy;
-using ::wcscat;
-using ::wcsncat;
-using ::wcscmp;
-using ::wcscoll;
-using ::wcsncmp;
-using ::wcsxfrm;
-using ::wcschr;
-using ::wcspbrk;
-using ::wcsrchr;
-using ::wcsstr;
-using ::wmemchr;
-using ::wcscspn;
-using ::wcslen;
-using ::wcsspn;
-using ::wcstok;
-using ::wmemcmp;
-using ::wmemcpy;
-using ::wmemmove;
-using ::wmemset;
-using ::wcsftime;
-using ::btowc;
-using ::wctob;
-using ::mbsinit;
-using ::mbrlen;
-using ::mbrtowc;
-using ::wcrtomb;
-using ::mbsrtowcs;
-using ::wcsrtombs;
+using ::wcscpy _LIBCPP_USING_IF_EXISTS;
+using ::wcsncpy _LIBCPP_USING_IF_EXISTS;
+using ::wcscat _LIBCPP_USING_IF_EXISTS;
+using ::wcsncat _LIBCPP_USING_IF_EXISTS;
+using ::wcscmp _LIBCPP_USING_IF_EXISTS;
+using ::wcscoll _LIBCPP_USING_IF_EXISTS;
+using ::wcsncmp _LIBCPP_USING_IF_EXISTS;
+using ::wcsxfrm _LIBCPP_USING_IF_EXISTS;
+using ::wcschr _LIBCPP_USING_IF_EXISTS;
+using ::wcspbrk _LIBCPP_USING_IF_EXISTS;
+using ::wcsrchr _LIBCPP_USING_IF_EXISTS;
+using ::wcsstr _LIBCPP_USING_IF_EXISTS;
+using ::wmemchr _LIBCPP_USING_IF_EXISTS;
+using ::wcscspn _LIBCPP_USING_IF_EXISTS;
+using ::wcslen _LIBCPP_USING_IF_EXISTS;
+using ::wcsspn _LIBCPP_USING_IF_EXISTS;
+using ::wcstok _LIBCPP_USING_IF_EXISTS;
+using ::wmemcmp _LIBCPP_USING_IF_EXISTS;
+using ::wmemcpy _LIBCPP_USING_IF_EXISTS;
+using ::wmemmove _LIBCPP_USING_IF_EXISTS;
+using ::wmemset _LIBCPP_USING_IF_EXISTS;
+using ::wcsftime _LIBCPP_USING_IF_EXISTS;
+using ::btowc _LIBCPP_USING_IF_EXISTS;
+using ::wctob _LIBCPP_USING_IF_EXISTS;
+using ::mbsinit _LIBCPP_USING_IF_EXISTS;
+using ::mbrlen _LIBCPP_USING_IF_EXISTS;
+using ::mbrtowc _LIBCPP_USING_IF_EXISTS;
+using ::wcrtomb _LIBCPP_USING_IF_EXISTS;
+using ::mbsrtowcs _LIBCPP_USING_IF_EXISTS;
+using ::wcsrtombs _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_STDIN
-using ::getwchar;
-using ::vwscanf;
-using ::wscanf;
+using ::getwchar _LIBCPP_USING_IF_EXISTS;
+using ::vwscanf _LIBCPP_USING_IF_EXISTS;
+using ::wscanf _LIBCPP_USING_IF_EXISTS;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
-using ::putwchar;
-using ::vwprintf;
-using ::wprintf;
+using ::putwchar _LIBCPP_USING_IF_EXISTS;
+using ::vwprintf _LIBCPP_USING_IF_EXISTS;
+using ::wprintf _LIBCPP_USING_IF_EXISTS;
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CWCHAR
+#endif // _LIBCPP_CWCHAR
diff --git a/contrib/llvm-project/libcxx/include/cwctype b/contrib/llvm-project/libcxx/include/cwctype
index 575fd5661293..17c68d6d4544 100644
--- a/contrib/llvm-project/libcxx/include/cwctype
+++ b/contrib/llvm-project/libcxx/include/cwctype
@@ -59,28 +59,28 @@ wctrans_t wctrans(const char* property);
_LIBCPP_BEGIN_NAMESPACE_STD
-using ::wint_t;
-using ::wctrans_t;
-using ::wctype_t;
-using ::iswalnum;
-using ::iswalpha;
-using ::iswblank;
-using ::iswcntrl;
-using ::iswdigit;
-using ::iswgraph;
-using ::iswlower;
-using ::iswprint;
-using ::iswpunct;
-using ::iswspace;
-using ::iswupper;
-using ::iswxdigit;
-using ::iswctype;
-using ::wctype;
-using ::towlower;
-using ::towupper;
-using ::towctrans;
-using ::wctrans;
+using ::wint_t _LIBCPP_USING_IF_EXISTS;
+using ::wctrans_t _LIBCPP_USING_IF_EXISTS;
+using ::wctype_t _LIBCPP_USING_IF_EXISTS;
+using ::iswalnum _LIBCPP_USING_IF_EXISTS;
+using ::iswalpha _LIBCPP_USING_IF_EXISTS;
+using ::iswblank _LIBCPP_USING_IF_EXISTS;
+using ::iswcntrl _LIBCPP_USING_IF_EXISTS;
+using ::iswdigit _LIBCPP_USING_IF_EXISTS;
+using ::iswgraph _LIBCPP_USING_IF_EXISTS;
+using ::iswlower _LIBCPP_USING_IF_EXISTS;
+using ::iswprint _LIBCPP_USING_IF_EXISTS;
+using ::iswpunct _LIBCPP_USING_IF_EXISTS;
+using ::iswspace _LIBCPP_USING_IF_EXISTS;
+using ::iswupper _LIBCPP_USING_IF_EXISTS;
+using ::iswxdigit _LIBCPP_USING_IF_EXISTS;
+using ::iswctype _LIBCPP_USING_IF_EXISTS;
+using ::wctype _LIBCPP_USING_IF_EXISTS;
+using ::towlower _LIBCPP_USING_IF_EXISTS;
+using ::towupper _LIBCPP_USING_IF_EXISTS;
+using ::towctrans _LIBCPP_USING_IF_EXISTS;
+using ::wctrans _LIBCPP_USING_IF_EXISTS;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_CWCTYPE
+#endif // _LIBCPP_CWCTYPE
diff --git a/contrib/llvm-project/libcxx/include/deque b/contrib/llvm-project/libcxx/include/deque
index c6517d170f34..aff93deb1010 100644
--- a/contrib/llvm-project/libcxx/include/deque
+++ b/contrib/llvm-project/libcxx/include/deque
@@ -161,12 +161,16 @@ template <class T, class Allocator, class Predicate>
*/
#include <__config>
+#include <__debug>
#include <__split_buffer>
-#include <type_traits>
+#include <__utility/forward.h>
+#include <algorithm>
+#include <compare>
#include <initializer_list>
#include <iterator>
-#include <algorithm>
+#include <limits>
#include <stdexcept>
+#include <type_traits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -1055,7 +1059,7 @@ public:
__deque_base(__deque_base&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
__deque_base(__deque_base&& __c, const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
void swap(__deque_base& __c)
#if _LIBCPP_STD_VER >= 14
@@ -1222,7 +1226,7 @@ __deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
void
@@ -1315,7 +1319,7 @@ public:
deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
deque(const deque& __c);
- deque(const deque& __c, const allocator_type& __a);
+ deque(const deque& __c, const __identity_t<allocator_type>& __a);
deque& operator=(const deque& __c);
@@ -1329,7 +1333,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
_LIBCPP_INLINE_VISIBILITY
- deque(deque&& __c, const allocator_type& __a);
+ deque(deque&& __c, const __identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
deque& operator=(deque&& __c)
_NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -1337,7 +1341,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _InputIter>
void assign(_InputIter __f, _InputIter __l,
@@ -1440,7 +1444,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, initializer_list<value_type> __il)
{return insert(__p, __il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
iterator insert(const_iterator __p, const value_type& __v);
iterator insert(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIter>
@@ -1586,18 +1590,18 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
deque(_InputIterator, _InputIterator)
- -> deque<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> deque<__iter_value_type<_InputIterator>, _Alloc>;
template<class _InputIterator,
class _Alloc,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
deque(_InputIterator, _InputIterator, _Alloc)
- -> deque<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> deque<__iter_value_type<_InputIterator>, _Alloc>;
#endif
@@ -1658,7 +1662,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c)
}
template <class _Tp, class _Allocator>
-deque<_Tp, _Allocator>::deque(const deque& __c, const allocator_type& __a)
+deque<_Tp, _Allocator>::deque(const deque& __c, const __identity_t<allocator_type>& __a)
: __base(__a)
{
__append(__c.begin(), __c.end());
@@ -1701,7 +1705,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c)
template <class _Tp, class _Allocator>
inline
-deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a)
+deque<_Tp, _Allocator>::deque(deque&& __c, const __identity_t<allocator_type>& __a)
: __base(_VSTD::move(__c), __a)
{
if (__a != __c.__alloc())
@@ -1746,7 +1750,7 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
__base::__move_assign(__c);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
template <class _InputIter>
@@ -2128,7 +2132,7 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
return __base::begin() + __pos;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
@@ -2532,7 +2536,7 @@ deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __nb > 0; --__nb)
__buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2544,7 +2548,7 @@ deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)
__alloc_traits::deallocate(__a, *__i, __base::__block_size);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __back_capacity > 0; --__back_capacity)
{
__buf.push_back(__base::__map_.back());
@@ -2674,7 +2678,7 @@ deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __nb > 0; --__nb)
__buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2686,7 +2690,7 @@ deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)
__alloc_traits::deallocate(__a, *__i, __base::__block_size);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __front_capacity > 0; --__front_capacity)
{
__buf.push_back(__base::__map_.front());
@@ -2720,7 +2724,7 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::pop_back()
{
- _LIBCPP_ASSERT(!empty(), "deque::pop_back called for empty deque");
+ _LIBCPP_ASSERT(!empty(), "deque::pop_back called on an empty deque");
allocator_type& __a = __base::__alloc();
size_type __p = __base::size() + __base::__start_ - 1;
__alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
@@ -3044,4 +3048,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_DEQUE
+#endif // _LIBCPP_DEQUE
diff --git a/contrib/llvm-project/libcxx/include/errno.h b/contrib/llvm-project/libcxx/include/errno.h
index f2d13b9a9904..0982da952e2a 100644
--- a/contrib/llvm-project/libcxx/include/errno.h
+++ b/contrib/llvm-project/libcxx/include/errno.h
@@ -428,4 +428,4 @@ static const int __elast3 = 106;
#endif // __cplusplus
-#endif // _LIBCPP_ERRNO_H
+#endif // _LIBCPP_ERRNO_H
diff --git a/contrib/llvm-project/libcxx/include/exception b/contrib/llvm-project/libcxx/include/exception
index 4bf4049f3325..816f259f878b 100644
--- a/contrib/llvm-project/libcxx/include/exception
+++ b/contrib/llvm-project/libcxx/include/exception
@@ -76,9 +76,9 @@ template <class E> void rethrow_if_nested(const E& e);
*/
-#include <__config>
#include <__availability>
-#include <__memory/base.h>
+#include <__config>
+#include <__memory/addressof.h>
#include <cstddef>
#include <cstdlib>
#include <type_traits>
@@ -151,7 +151,7 @@ public:
exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
~exception_ptr() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY explicit operator bool() const _NOEXCEPT
{return __ptr_ != nullptr;}
friend _LIBCPP_INLINE_VISIBILITY
@@ -205,7 +205,7 @@ public:
exception_ptr& operator=(const exception_ptr& __other) _NOEXCEPT;
exception_ptr& operator=(nullptr_t) _NOEXCEPT;
~exception_ptr() _NOEXCEPT;
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT;
+ explicit operator bool() const _NOEXCEPT;
};
_LIBCPP_FUNC_VIS
@@ -266,7 +266,7 @@ struct __throw_with_nested<_Tp, _Up, true> {
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
__do_throw(_Tp&& __t)
{
- throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
+ throw __nested<_Up>(static_cast<_Tp&&>(__t));
}
};
@@ -277,9 +277,9 @@ struct __throw_with_nested<_Tp, _Up, false> {
__do_throw(_Tp&& __t)
#else
__do_throw (_Tp& __t)
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
{
- throw _VSTD::forward<_Tp>(__t);
+ throw static_cast<_Tp&&>(__t);
}
};
#endif
@@ -296,7 +296,7 @@ throw_with_nested(_Tp&& __t)
is_class<_Up>::value &&
!is_base_of<nested_exception, _Up>::value &&
!__libcpp_is_final<_Up>::value>::
- __do_throw(_VSTD::forward<_Tp>(__t));
+ __do_throw(static_cast<_Tp&&>(__t));
#else
((void)__t);
// FIXME: Make this abort
@@ -330,4 +330,4 @@ rethrow_if_nested(const _Ep&,
} // std
-#endif // _LIBCPP_EXCEPTION
+#endif // _LIBCPP_EXCEPTION
diff --git a/contrib/llvm-project/libcxx/include/experimental/__config b/contrib/llvm-project/libcxx/include/experimental/__config
index 375dc3743fcf..f85426d050d1 100644
--- a/contrib/llvm-project/libcxx/include/experimental/__config
+++ b/contrib/llvm-project/libcxx/include/experimental/__config
@@ -32,10 +32,6 @@
#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
-#define _LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS _LIBCPP_BEGIN_NAMESPACE_STD \
- namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
-#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
-
#if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM)
# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */
#else
diff --git a/contrib/llvm-project/libcxx/include/experimental/__memory b/contrib/llvm-project/libcxx/include/experimental/__memory
index 4cf8978468ce..b38b664b339a 100644
--- a/contrib/llvm-project/libcxx/include/experimental/__memory
+++ b/contrib/llvm-project/libcxx/include/experimental/__memory
@@ -10,6 +10,8 @@
#ifndef _LIBCPP_EXPERIMENTAL___MEMORY
#define _LIBCPP_EXPERIMENTAL___MEMORY
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
#include <experimental/__config>
#include <experimental/utility> // for erased_type
#include <__functional_base>
@@ -73,12 +75,35 @@ struct __lfts_uses_alloc_ctor
>
{};
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
+{
+ new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
+}
+
+// FIXME: This should have a version which takes a non-const alloc.
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+ new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
+}
+
+// FIXME: This should have a version which takes a non-const alloc.
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+ new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
+}
+
template <class _Tp, class _Alloc, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
void __lfts_user_alloc_construct(
_Tp * __store, const _Alloc & __a, _Args &&... __args)
{
- _VSTD::__user_alloc_construct_impl(
+ ::std::experimental::fundamentals_v1::__user_alloc_construct_impl(
typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type()
, __store, __a, _VSTD::forward<_Args>(__args)...
);
diff --git a/contrib/llvm-project/libcxx/include/experimental/functional b/contrib/llvm-project/libcxx/include/experimental/functional
index c7dda2254b39..e3220e16caeb 100644
--- a/contrib/llvm-project/libcxx/include/experimental/functional
+++ b/contrib/llvm-project/libcxx/include/experimental/functional
@@ -86,6 +86,7 @@ inline namespace fundamentals_v1 {
*/
+#include <__memory/uses_allocator.h>
#include <experimental/__config>
#include <functional>
#include <algorithm>
@@ -109,7 +110,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
#if _LIBCPP_STD_VER > 11
// default searcher
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TYPE_VIS default_searcher {
+class _LIBCPP_TEMPLATE_VIS default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
@@ -122,8 +123,8 @@ public:
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
{
return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
- typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
- typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
+ typename iterator_traits<_ForwardIterator>::iterator_category(),
+ typename iterator_traits<_ForwardIterator2>::iterator_category());
}
private:
@@ -154,7 +155,7 @@ public: // TODO private:
public:
_LIBCPP_INLINE_VISIBILITY
- _BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
+ _BMSkipTable(size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
: __default_value_(__default), __table(__sz, __hf, __pred) {}
_LIBCPP_INLINE_VISIBILITY
@@ -179,13 +180,13 @@ private:
typedef _Value value_type;
typedef _Key key_type;
- typedef typename std::make_unsigned<key_type>::type unsigned_key_type;
- typedef std::array<value_type, _VSTD::numeric_limits<unsigned_key_type>::max()> skip_map;
+ typedef typename make_unsigned<key_type>::type unsigned_key_type;
+ typedef std::array<value_type, numeric_limits<unsigned_key_type>::max()> skip_map;
skip_map __table;
public:
_LIBCPP_INLINE_VISIBILITY
- _BMSkipTable(std::size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
+ _BMSkipTable(size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
{
std::fill_n(__table.begin(), __table.size(), __default);
}
@@ -207,12 +208,12 @@ public:
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TYPE_VIS boyer_moore_searcher {
+class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate,
- _VSTD::is_integral<value_type>::value && // what about enums?
+ is_integral<value_type>::value && // what about enums?
sizeof(value_type) == 1 &&
is_same<_Hash, hash<value_type>>::value &&
is_same<_BinaryPredicate, equal_to<>>::value
@@ -247,7 +248,7 @@ public:
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
- if ( __pattern_length_ > _VSTD::distance (__f, __l))
+ if ( __pattern_length_ > _VSTD::distance(__f, __l))
return make_pair(__l, __l);
// Do the search
@@ -299,11 +300,11 @@ public: // TODO private:
template<typename _Iterator, typename _Container>
void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix )
{
- const std::size_t __count = _VSTD::distance(__f, __l);
+ const size_t __count = _VSTD::distance(__f, __l);
__prefix[0] = 0;
- std::size_t __k = 0;
- for ( std::size_t __i = 1; __i < __count; ++__i )
+ size_t __k = 0;
+ for ( size_t __i = 1; __i < __count; ++__i )
{
while ( __k > 0 && !__pred ( __f[__k], __f[__i] ))
__k = __prefix [ __k - 1 ];
@@ -317,22 +318,22 @@ public: // TODO private:
void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l,
_BinaryPredicate __pred)
{
- const std::size_t __count = _VSTD::distance(__f, __l);
+ const size_t __count = _VSTD::distance(__f, __l);
vector<difference_type> & __suffix = *__suffix_.get();
if (__count > 0)
{
- _VSTD::vector<value_type> __scratch(__count);
+ vector<value_type> __scratch(__count);
__compute_bm_prefix(__f, __l, __pred, __scratch);
- for ( std::size_t __i = 0; __i <= __count; __i++ )
+ for ( size_t __i = 0; __i <= __count; __i++ )
__suffix[__i] = __count - __scratch[__count-1];
- typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter;
+ typedef reverse_iterator<_RandomAccessIterator1> _RevIter;
__compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch);
- for ( std::size_t __i = 0; __i < __count; __i++ )
+ for ( size_t __i = 0; __i < __count; __i++ )
{
- const std::size_t __j = __count - __scratch[__i];
+ const size_t __j = __count - __scratch[__i];
const difference_type __k = __i - __scratch[__i] + 1;
if (__suffix[__j] > __k)
@@ -358,12 +359,12 @@ make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TYPE_VIS boyer_moore_horspool_searcher {
+class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
typedef _BMSkipTable<value_type, difference_type, _Hash, _BinaryPredicate,
- _VSTD::is_integral<value_type>::value && // what about enums?
+ is_integral<value_type>::value && // what about enums?
sizeof(value_type) == 1 &&
is_same<_Hash, hash<value_type>>::value &&
is_same<_BinaryPredicate, equal_to<>>::value
@@ -399,7 +400,7 @@ public:
if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
// If the pattern is larger than the corpus, we can't find it!
- if ( __pattern_length_ > _VSTD::distance (__f, __l))
+ if ( __pattern_length_ > _VSTD::distance(__f, __l))
return make_pair(__l, __l);
// Do the search
diff --git a/contrib/llvm-project/libcxx/include/experimental/iterator b/contrib/llvm-project/libcxx/include/experimental/iterator
index 10b0599138c6..09ea2cbcc7dc 100644
--- a/contrib/llvm-project/libcxx/include/experimental/iterator
+++ b/contrib/llvm-project/libcxx/include/experimental/iterator
@@ -56,6 +56,9 @@ namespace std {
#if _LIBCPP_STD_VER > 11
+#include <__memory/addressof.h>
+#include <__utility/move.h>
+#include <__utility/forward.h>
#include <iterator>
_LIBCPP_BEGIN_NAMESPACE_LFTS
diff --git a/contrib/llvm-project/libcxx/include/experimental/propagate_const b/contrib/llvm-project/libcxx/include/experimental/propagate_const
index 59f50c5e574d..ce4b879b7eab 100644
--- a/contrib/llvm-project/libcxx/include/experimental/propagate_const
+++ b/contrib/llvm-project/libcxx/include/experimental/propagate_const
@@ -135,7 +135,7 @@ template <class _Tp>
class propagate_const
{
public:
- typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type;
+ typedef remove_reference_t<decltype(*declval<_Tp&>())> element_type;
static_assert(!is_array<_Tp>::value,
"Instantiation of propagate_const with an array type is ill-formed.");
diff --git a/contrib/llvm-project/libcxx/include/experimental/simd b/contrib/llvm-project/libcxx/include/experimental/simd
index 41f8f799a0b0..d1aaf5504488 100644
--- a/contrib/llvm-project/libcxx/include/experimental/simd
+++ b/contrib/llvm-project/libcxx/include/experimental/simd
@@ -725,12 +725,12 @@ constexpr size_t __ceil_pow_of_2(size_t __val) {
template <class _Tp, size_t __bytes>
struct __vec_ext_traits {
-#if !defined(_LIBCPP_COMPILER_CLANG)
+#if !defined(_LIBCPP_COMPILER_CLANG_BASED)
typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes))));
#endif
};
-#if defined(_LIBCPP_COMPILER_CLANG)
+#if defined(_LIBCPP_COMPILER_CLANG_BASED)
#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT) \
template <> \
struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> { \
diff --git a/contrib/llvm-project/libcxx/include/experimental/type_traits b/contrib/llvm-project/libcxx/include/experimental/type_traits
index 7ab097226b5d..ea1335f96af5 100644
--- a/contrib/llvm-project/libcxx/include/experimental/type_traits
+++ b/contrib/llvm-project/libcxx/include/experimental/type_traits
@@ -105,7 +105,7 @@ using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
// 3.3.4, Detection idiom
template <class...> using void_t = void;
-struct nonesuch : private _VSTD::__nat { // make nonesuch "not an aggregate"
+struct nonesuch : private __nat { // make nonesuch "not an aggregate"
~nonesuch() = delete;
nonesuch (nonesuch const&) = delete;
void operator=(nonesuch const&) = delete;
diff --git a/contrib/llvm-project/libcxx/include/ext/__hash b/contrib/llvm-project/libcxx/include/ext/__hash
index d03f101e95a1..fbeddf03a404 100644
--- a/contrib/llvm-project/libcxx/include/ext/__hash
+++ b/contrib/llvm-project/libcxx/include/ext/__hash
@@ -12,6 +12,7 @@
#pragma GCC system_header
+#include <__string>
#include <string>
#include <cstring>
@@ -130,4 +131,4 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
};
}
-#endif // _LIBCPP_EXT_HASH
+#endif // _LIBCPP_EXT_HASH
diff --git a/contrib/llvm-project/libcxx/include/ext/hash_map b/contrib/llvm-project/libcxx/include/ext/hash_map
index 2d6024cb9036..60e32b09e3e1 100644
--- a/contrib/llvm-project/libcxx/include/ext/hash_map
+++ b/contrib/llvm-project/libcxx/include/ext/hash_map
@@ -208,7 +208,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <type_traits>
#include <ext/__hash>
-#if __DEPRECATED
+#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
#else
@@ -350,7 +350,7 @@ public:
{
const_cast<bool&>(__x.__value_constructed) = false;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p)
@@ -981,4 +981,4 @@ operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
} // __gnu_cxx
-#endif // _LIBCPP_HASH_MAP
+#endif // _LIBCPP_HASH_MAP
diff --git a/contrib/llvm-project/libcxx/include/ext/hash_set b/contrib/llvm-project/libcxx/include/ext/hash_set
index f0ba8d8ded95..af3f9c5de0c5 100644
--- a/contrib/llvm-project/libcxx/include/ext/hash_set
+++ b/contrib/llvm-project/libcxx/include/ext/hash_set
@@ -197,7 +197,7 @@ template <class Value, class Hash, class Pred, class Alloc>
#include <functional>
#include <ext/__hash>
-#if __DEPRECATED
+#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
_LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
#else
@@ -656,4 +656,4 @@ operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
} // __gnu_cxx
-#endif // _LIBCPP_HASH_SET
+#endif // _LIBCPP_HASH_SET
diff --git a/contrib/llvm-project/libcxx/include/filesystem b/contrib/llvm-project/libcxx/include/filesystem
index 92e37e183def..61d6c659cb47 100644
--- a/contrib/llvm-project/libcxx/include/filesystem
+++ b/contrib/llvm-project/libcxx/include/filesystem
@@ -229,19 +229,22 @@
*/
-#include <__config>
#include <__availability>
+#include <__config>
+#include <__debug>
+#include <__utility/forward.h>
+#include <chrono>
+#include <compare>
#include <cstddef>
#include <cstdlib>
-#include <chrono>
-#include <iterator>
#include <iosfwd>
+#include <iterator>
#include <memory>
#include <stack>
#include <string>
+#include <string_view>
#include <system_error>
#include <utility>
-#include <string_view>
#include <version>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -249,8 +252,6 @@
# include <iomanip> // for quoted
#endif
-#include <__debug>
-
#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
# error "The Filesystem library is not supported by this configuration of libc++"
#endif
@@ -276,6 +277,8 @@ struct _LIBCPP_TYPE_VIS space_info {
uintmax_t available;
};
+// On Windows, the library never identifies files as block, character, fifo
+// or socket.
enum class _LIBCPP_ENUM_VIS file_type : signed char {
none = 0,
not_found = -1,
@@ -289,6 +292,10 @@ enum class _LIBCPP_ENUM_VIS file_type : signed char {
unknown = 8
};
+// On Windows, these permission bits map to one single readonly flag per
+// file, and the executable bit is always returned as set. When setting
+// permissions, as long as the write bit is set for either owner, group or
+// others, the readonly flag is cleared.
enum class _LIBCPP_ENUM_VIS perms : unsigned {
none = 0,
@@ -551,7 +558,7 @@ struct __can_convert_char<wchar_t> {
static const bool value = true;
using __char_type = wchar_t;
};
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <>
struct __can_convert_char<char8_t> {
static const bool value = true;
@@ -579,7 +586,7 @@ __is_separator(_ECharT __e) {
#endif
}
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef u8string __u8_string;
#else
typedef string __u8_string;
@@ -785,7 +792,7 @@ struct _PathCVT<__path_value> {
template <class _Iter>
static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type
__append_range(__path_string& __dest, _Iter __b, _Iter __e) {
- __dest.__append_forward_unsafe(__b, __e);
+ __dest.append(__b, __e);
}
template <class _Iter>
@@ -886,7 +893,7 @@ struct _PathExport<char16_t> {
}
};
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <>
struct _PathExport<char8_t> {
typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
@@ -896,7 +903,7 @@ struct _PathExport<char8_t> {
_Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size());
}
};
-#endif /* !_LIBCPP_NO_HAS_CHAR8_T */
+#endif /* !_LIBCPP_HAS_NO_CHAR8_T */
#endif /* _LIBCPP_WIN32API */
class _LIBCPP_TYPE_VIS path {
@@ -921,7 +928,7 @@ public:
typedef basic_string<value_type> string_type;
typedef basic_string_view<value_type> __string_view;
- enum class _LIBCPP_ENUM_VIS format : unsigned char {
+ enum _LIBCPP_ENUM_VIS format : unsigned char {
auto_format,
native_format,
generic_format
@@ -973,8 +980,8 @@ public:
return *this;
}
- template <class = void>
- _LIBCPP_INLINE_VISIBILITY path& operator=(string_type&& __s) noexcept {
+ _LIBCPP_INLINE_VISIBILITY
+ path& operator=(string_type&& __s) noexcept {
__pn_ = _VSTD::move(__s);
return *this;
}
@@ -1006,14 +1013,44 @@ public:
return *this;
}
-private:
- template <class _ECharT>
- static bool __source_is_absolute(_ECharT __first_or_null) {
- return __is_separator(__first_or_null);
- }
-
public:
// appends
+#if defined(_LIBCPP_WIN32API)
+ path& operator/=(const path& __p) {
+ auto __p_root_name = __p.__root_name();
+ auto __p_root_name_size = __p_root_name.size();
+ if (__p.is_absolute() ||
+ (!__p_root_name.empty() && __p_root_name != root_name())) {
+ __pn_ = __p.__pn_;
+ return *this;
+ }
+ if (__p.has_root_directory()) {
+ path __root_name_str = root_name();
+ __pn_ = __root_name_str.native();
+ __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size);
+ return *this;
+ }
+ if (has_filename() || (!has_root_directory() && is_absolute()))
+ __pn_ += preferred_separator;
+ __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size);
+ return *this;
+ }
+ template <class _Source>
+ _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source>
+ operator/=(const _Source& __src) {
+ return operator/=(path(__src));
+ }
+
+ template <class _Source>
+ _EnableIfPathable<_Source> append(const _Source& __src) {
+ return operator/=(path(__src));
+ }
+
+ template <class _InputIt>
+ path& append(_InputIt __first, _InputIt __last) {
+ return operator/=(path(__first, __last));
+ }
+#else
path& operator/=(const path& __p) {
if (__p.is_absolute()) {
__pn_ = __p.__pn_;
@@ -1038,7 +1075,8 @@ public:
_EnableIfPathable<_Source> append(const _Source& __src) {
using _Traits = __is_pathable<_Source>;
using _CVT = _PathCVT<_SourceChar<_Source> >;
- if (__source_is_absolute(_Traits::__first_or_null(__src)))
+ bool __source_is_absolute = __is_separator(_Traits::__first_or_null(__src));
+ if (__source_is_absolute)
__pn_.clear();
else if (has_filename())
__pn_ += preferred_separator;
@@ -1051,13 +1089,14 @@ public:
typedef typename iterator_traits<_InputIt>::value_type _ItVal;
static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
using _CVT = _PathCVT<_ItVal>;
- if (__first != __last && __source_is_absolute(*__first))
+ if (__first != __last && __is_separator(*__first))
__pn_.clear();
else if (has_filename())
__pn_ += preferred_separator;
_CVT::__append_range(__pn_, __first, __last);
return *this;
}
+#endif
// concatenation
_LIBCPP_INLINE_VISIBILITY
@@ -1161,7 +1200,12 @@ public:
#if defined(_LIBCPP_WIN32API)
_LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; }
- _VSTD::wstring generic_wstring() const { return __pn_; }
+ _VSTD::wstring generic_wstring() const {
+ _VSTD::wstring __s;
+ __s.resize(__pn_.size());
+ _VSTD::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/');
+ return __s;
+ }
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
template <class _ECharT, class _Traits = char_traits<_ECharT>,
@@ -1198,18 +1242,29 @@ public:
class _Allocator = allocator<_ECharT> >
basic_string<_ECharT, _Traits, _Allocator>
generic_string(const _Allocator& __a = _Allocator()) const {
- return string<_ECharT, _Traits, _Allocator>(__a);
+ using _Str = basic_string<_ECharT, _Traits, _Allocator>;
+ _Str __s = string<_ECharT, _Traits, _Allocator>(__a);
+ // Note: This (and generic_u8string below) is slightly suboptimal as
+ // it iterates twice over the string; once to convert it to the right
+ // character type, and once to replace path delimiters.
+ _VSTD::replace(__s.begin(), __s.end(),
+ static_cast<_ECharT>('\\'), static_cast<_ECharT>('/'));
+ return __s;
}
_VSTD::string generic_string() const { return generic_string<char>(); }
_VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); }
_VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); }
- __u8_string generic_u8string() const { return u8string(); }
+ __u8_string generic_u8string() const {
+ __u8_string __s = u8string();
+ _VSTD::replace(__s.begin(), __s.end(), '\\', '/');
+ return __s;
+ }
#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */
#else /* _LIBCPP_WIN32API */
_LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; }
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
_LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
#else
_LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; }
@@ -1241,7 +1296,7 @@ public:
// generic format observers
_VSTD::string generic_string() const { return __pn_; }
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
_VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); }
#else
_VSTD::string generic_u8string() const { return __pn_; }
@@ -1295,7 +1350,11 @@ public:
return string_type(__root_directory());
}
_LIBCPP_INLINE_VISIBILITY path root_path() const {
+#if defined(_LIBCPP_WIN32API)
+ return string_type(__root_path_raw());
+#else
return root_name().append(string_type(__root_directory()));
+#endif
}
_LIBCPP_INLINE_VISIBILITY path relative_path() const {
return string_type(__relative_path());
@@ -1341,7 +1400,28 @@ public:
}
_LIBCPP_INLINE_VISIBILITY bool is_absolute() const {
+#if defined(_LIBCPP_WIN32API)
+ __string_view __root_name_str = __root_name();
+ __string_view __root_dir = __root_directory();
+ if (__root_name_str.size() == 2 && __root_name_str[1] == ':') {
+ // A drive letter with no root directory is relative, e.g. x:example.
+ return !__root_dir.empty();
+ }
+ // If no root name, it's relative, e.g. \example is relative to the current drive
+ if (__root_name_str.empty())
+ return false;
+ if (__root_name_str.size() < 3)
+ return false;
+ // A server root name, like \\server, is always absolute
+ if (__root_name_str[0] != '/' && __root_name_str[0] != '\\')
+ return false;
+ if (__root_name_str[1] != '/' && __root_name_str[1] != '\\')
+ return false;
+ // Seems to be a server root name
+ return true;
+#else
return has_root_directory();
+#endif
}
_LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); }
@@ -1440,7 +1520,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
typename enable_if<__is_pathable<_InputIt>::value, path>::type
u8path(_InputIt __f, _InputIt __l) {
static_assert(
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
#endif
is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
@@ -1464,7 +1544,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
typename enable_if<__is_pathable<_InputIt>::value, path>::type
u8path(_InputIt __f, _NullSentinel) {
static_assert(
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
#endif
is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
@@ -1487,7 +1567,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
typename enable_if<__is_pathable<_Source>::value, path>::type
u8path(const _Source& __s) {
static_assert(
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value ||
#endif
is_same<typename __is_pathable<_Source>::__char_type, char>::value,
@@ -1495,7 +1575,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
"'char' or 'char8_t'");
#if defined(_LIBCPP_WIN32API)
using _Traits = __is_pathable<_Source>;
- return u8path(__unwrap_iter(_Traits::__range_begin(__s)), __unwrap_iter(_Traits::__range_end(__s)));
+ return u8path(_VSTD::__unwrap_iter(_Traits::__range_begin(__s)), _VSTD::__unwrap_iter(_Traits::__range_end(__s)));
#else
return path(__s);
#endif
diff --git a/contrib/llvm-project/libcxx/include/float.h b/contrib/llvm-project/libcxx/include/float.h
index 5c1e1db79766..399ab4f11a5d 100644
--- a/contrib/llvm-project/libcxx/include/float.h
+++ b/contrib/llvm-project/libcxx/include/float.h
@@ -90,4 +90,4 @@ Macros:
#endif // __cplusplus
-#endif // _LIBCPP_FLOAT_H
+#endif // _LIBCPP_FLOAT_H
diff --git a/contrib/llvm-project/libcxx/include/format b/contrib/llvm-project/libcxx/include/format
new file mode 100644
index 000000000000..0ec4b85ca0a5
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/format
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//===--------------------------- format -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FORMAT
+#define _LIBCPP_FORMAT
+
+/*
+
+namespace std {
+ // [format.error], class format_error
+ class format_error : public runtime_error {
+ public:
+ explicit format_error(const string& what_arg);
+ explicit format_error(const char* what_arg);
+ };
+
+ // [format.parse.ctx], class template basic_format_parse_context
+ template<class charT>
+ class basic_format_parse_context {
+ public:
+ using char_type = charT;
+ using const_iterator = typename basic_string_view<charT>::const_iterator;
+ using iterator = const_iterator;
+
+ private:
+ iterator begin_; // exposition only
+ iterator end_; // exposition only
+ enum indexing { unknown, manual, automatic }; // exposition only
+ indexing indexing_; // exposition only
+ size_t next_arg_id_; // exposition only
+ size_t num_args_; // exposition only
+
+ public:
+ constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
+ size_t num_args = 0) noexcept;
+ basic_format_parse_context(const basic_format_parse_context&) = delete;
+ basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
+
+ constexpr const_iterator begin() const noexcept;
+ constexpr const_iterator end() const noexcept;
+ constexpr void advance_to(const_iterator it);
+
+ constexpr size_t next_arg_id();
+ constexpr void check_arg_id(size_t id);
+ };
+ using format_parse_context = basic_format_parse_context<char>;
+ using wformat_parse_context = basic_format_parse_context<wchar_t>;
+}
+
+*/
+
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <version>
+
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+# error "The Format library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_FORMAT
diff --git a/contrib/llvm-project/libcxx/include/forward_list b/contrib/llvm-project/libcxx/include/forward_list
index d3d6b8238f6b..0ae8f19ec20c 100644
--- a/contrib/llvm-project/libcxx/include/forward_list
+++ b/contrib/llvm-project/libcxx/include/forward_list
@@ -180,11 +180,12 @@ template <class T, class Allocator, class Predicate>
*/
#include <__config>
+#include <__utility/forward.h>
+#include <algorithm>
#include <initializer_list>
-#include <memory>
-#include <limits>
#include <iterator>
-#include <algorithm>
+#include <limits>
+#include <memory>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -272,7 +273,7 @@ struct _LIBCPP_HIDDEN __begin_node_of
};
template <class _Tp, class _VoidPtr>
-struct __forward_list_node
+struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
: public __begin_node_of<_Tp, _VoidPtr>::type
{
typedef _Tp value_type;
@@ -506,7 +507,7 @@ public:
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
_LIBCPP_INLINE_VISIBILITY
__forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
private:
__forward_list_base(const __forward_list_base&);
@@ -534,7 +535,7 @@ public:
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
- _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
+ _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value);
#endif
protected:
@@ -584,7 +585,7 @@ __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x,
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
__forward_list_base<_Tp, _Alloc>::~__forward_list_base()
@@ -599,7 +600,7 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
- _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
+ _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{
@@ -681,7 +682,7 @@ public:
__is_cpp17_input_iterator<_InputIterator>::value
>::type* = nullptr);
forward_list(const forward_list& __x);
- forward_list(const forward_list& __x, const allocator_type& __a);
+ forward_list(const forward_list& __x, const __identity_t<allocator_type>& __a);
forward_list& operator=(const forward_list& __x);
@@ -690,7 +691,7 @@ public:
forward_list(forward_list&& __x)
_NOEXCEPT_(is_nothrow_move_constructible<base>::value)
: base(_VSTD::move(__x)) {}
- forward_list(forward_list&& __x, const allocator_type& __a);
+ forward_list(forward_list&& __x, const __identity_t<allocator_type>& __a);
forward_list(initializer_list<value_type> __il);
forward_list(initializer_list<value_type> __il, const allocator_type& __a);
@@ -706,7 +707,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// ~forward_list() = default;
@@ -775,7 +776,7 @@ public:
template <class... _Args> void emplace_front(_Args&&... __args);
#endif
void push_front(value_type&& __v);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
void push_front(const value_type& __v);
void pop_front();
@@ -787,7 +788,7 @@ public:
iterator insert_after(const_iterator __p, value_type&& __v);
iterator insert_after(const_iterator __p, initializer_list<value_type> __il)
{return insert_after(__p, __il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
iterator insert_after(const_iterator __p, const value_type& __v);
iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIterator>
@@ -840,7 +841,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void merge(forward_list&& __x, _Compare __comp)
{merge(__x, _VSTD::move(__comp));}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void merge(forward_list& __x) {merge(__x, __less<value_type>());}
template <class _Compare> void merge(forward_list& __x, _Compare __comp);
@@ -855,7 +856,7 @@ private:
void __move_assign(forward_list& __x, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
void __move_assign(forward_list& __x, false_type);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Compare>
static
@@ -871,18 +872,18 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
forward_list(_InputIterator, _InputIterator)
- -> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
template<class _InputIterator,
class _Alloc,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
forward_list(_InputIterator, _InputIterator, _Alloc)
- -> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
#endif
template <class _Tp, class _Alloc>
@@ -979,7 +980,7 @@ forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,
- const allocator_type& __a)
+ const __identity_t<allocator_type>& __a)
: base(__a)
{
insert_after(cbefore_begin(), __x.begin(), __x.end());
@@ -1000,7 +1001,7 @@ forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,
- const allocator_type& __a)
+ const __identity_t<allocator_type>& __a)
: base(_VSTD::move(__x), __a)
{
if (base::__alloc() != __x.__alloc())
@@ -1070,7 +1071,7 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
template <class _InputIterator>
@@ -1150,7 +1151,7 @@ forward_list<_Tp, _Alloc>::push_front(value_type&& __v)
base::__before_begin()->__next_ = __h.release();
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
void
@@ -1207,7 +1208,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v)
return iterator(__r->__next_);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
typename forward_list<_Tp, _Alloc>::iterator
@@ -1240,7 +1241,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (--__n; __n != 0; --__n, __last = __last->__next_)
{
__h.reset(__node_traits::allocate(__a, 1));
@@ -1260,7 +1261,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
}
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__last->__next_ = __r->__next_;
__r->__next_ = __first;
__r = static_cast<__begin_node_pointer>(__last);
@@ -1290,7 +1291,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_)))
{
__h.reset(__node_traits::allocate(__a, 1));
@@ -1310,7 +1311,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
}
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__last->__next_ = __r->__next_;
__r->__next_ = __first;
__r = static_cast<__begin_node_pointer>(__last);
@@ -1784,4 +1785,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_FORWARD_LIST
+#endif // _LIBCPP_FORWARD_LIST
diff --git a/contrib/llvm-project/libcxx/include/fstream b/contrib/llvm-project/libcxx/include/fstream
index 7b1bbfe16c01..c522b8ab110d 100644
--- a/contrib/llvm-project/libcxx/include/fstream
+++ b/contrib/llvm-project/libcxx/include/fstream
@@ -179,13 +179,14 @@ typedef basic_fstream<wchar_t> wfstream;
*/
-#include <__config>
#include <__availability>
-#include <ostream>
-#include <istream>
+#include <__config>
+#include <__debug>
#include <__locale>
#include <cstdio>
#include <cstdlib>
+#include <istream>
+#include <ostream>
#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
# include <filesystem>
@@ -198,6 +199,9 @@ typedef basic_fstream<wchar_t> wfstream;
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
+#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
+# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
+#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -215,16 +219,12 @@ public:
// 27.9.1.2 Constructors/destructor:
basic_filebuf();
-#ifndef _LIBCPP_CXX03_LANG
basic_filebuf(basic_filebuf&& __rhs);
-#endif
virtual ~basic_filebuf();
// 27.9.1.3 Assign/swap:
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_filebuf& operator=(basic_filebuf&& __rhs);
-#endif
void swap(basic_filebuf& __rhs);
// 27.9.1.4 Members:
@@ -314,8 +314,6 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
setbuf(nullptr, 4096);
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
: basic_streambuf<_CharT, _Traits>(__rhs)
@@ -390,22 +388,20 @@ basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>::~basic_filebuf()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
close();
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (__owns_eb_)
delete [] __extbuf_;
if (__owns_ib_)
@@ -1160,13 +1156,10 @@ public:
: basic_ifstream(__p.c_str(), __mode) {}
#endif // _LIBCPP_STD_VER >= 17
#endif
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_ifstream(basic_ifstream&& __rhs);
-
_LIBCPP_INLINE_VISIBILITY
basic_ifstream& operator=(basic_ifstream&& __rhs);
-#endif
_LIBCPP_INLINE_VISIBILITY
void swap(basic_ifstream& __rhs);
@@ -1236,8 +1229,6 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::ope
}
#endif
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
inline
basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
@@ -1257,8 +1248,6 @@ basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
inline
void
@@ -1375,13 +1364,10 @@ public:
: basic_ofstream(__p.c_str(), __mode) {}
#endif // _LIBCPP_STD_VER >= 17
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_ofstream(basic_ofstream&& __rhs);
-
_LIBCPP_INLINE_VISIBILITY
basic_ofstream& operator=(basic_ofstream&& __rhs);
-#endif
_LIBCPP_INLINE_VISIBILITY
void swap(basic_ofstream& __rhs);
@@ -1450,8 +1436,6 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::ope
}
#endif
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
inline
basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
@@ -1471,8 +1455,6 @@ basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
inline
void
@@ -1591,13 +1573,12 @@ public:
#endif // _LIBCPP_STD_VER >= 17
#endif
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_fstream(basic_fstream&& __rhs);
_LIBCPP_INLINE_VISIBILITY
basic_fstream& operator=(basic_fstream&& __rhs);
-#endif
+
_LIBCPP_INLINE_VISIBILITY
void swap(basic_fstream& __rhs);
@@ -1664,8 +1645,6 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openm
}
#endif
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
inline
basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
@@ -1685,8 +1664,6 @@ basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
inline
void
@@ -1773,4 +1750,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_FSTREAM
+#endif // _LIBCPP_FSTREAM
diff --git a/contrib/llvm-project/libcxx/include/functional b/contrib/llvm-project/libcxx/include/functional
index 67baa5bd4b77..ecbc5667af18 100644
--- a/contrib/llvm-project/libcxx/include/functional
+++ b/contrib/llvm-project/libcxx/include/functional
@@ -1,5 +1,5 @@
// -*- C++ -*-
-//===------------------------ functional ----------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -42,8 +42,8 @@ public:
typedef see below result_type; // Not always defined
// construct/copy/destroy
- reference_wrapper(T&) noexcept;
- reference_wrapper(T&&) = delete; // do not bind to temps
+ template<class U>
+ reference_wrapper(U&&);
reference_wrapper(const reference_wrapper<T>& x) noexcept;
// assignment
@@ -59,6 +59,9 @@ public:
operator() (ArgTypes&&...) const;
};
+template <class T>
+ reference_wrapper(T&) -> reference_wrapper<T>;
+
template <class T> reference_wrapper<T> ref(T& t) noexcept;
template <class T> void ref(const T&& t) = delete;
template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
@@ -73,121 +76,104 @@ template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type
template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20
template <class T> // <class T=void> in C++14
-struct plus : binary_function<T, T, T>
-{
+struct plus {
T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct minus : binary_function<T, T, T>
-{
+struct minus {
T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct multiplies : binary_function<T, T, T>
-{
+struct multiplies {
T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct divides : binary_function<T, T, T>
-{
+struct divides {
T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct modulus : binary_function<T, T, T>
-{
+struct modulus {
T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct negate : unary_function<T, T>
-{
+struct negate {
T operator()(const T& x) const;
};
template <class T> // <class T=void> in C++14
-struct equal_to : binary_function<T, T, bool>
-{
+struct equal_to {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct not_equal_to : binary_function<T, T, bool>
-{
+struct not_equal_to {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct greater : binary_function<T, T, bool>
-{
+struct greater {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct less : binary_function<T, T, bool>
-{
+struct less {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct greater_equal : binary_function<T, T, bool>
-{
+struct greater_equal {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct less_equal : binary_function<T, T, bool>
-{
+struct less_equal {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct logical_and : binary_function<T, T, bool>
-{
+struct logical_and {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct logical_or : binary_function<T, T, bool>
-{
+struct logical_or {
bool operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct logical_not : unary_function<T, bool>
-{
+struct logical_not {
bool operator()(const T& x) const;
};
template <class T> // <class T=void> in C++14
-struct bit_and : unary_function<T, bool>
-{
- bool operator()(const T& x, const T& y) const;
+struct bit_and {
+ T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct bit_or : unary_function<T, bool>
-{
- bool operator()(const T& x, const T& y) const;
+struct bit_or {
+ T operator()(const T& x, const T& y) const;
};
template <class T> // <class T=void> in C++14
-struct bit_xor : unary_function<T, bool>
-{
- bool operator()(const T& x, const T& y) const;
+struct bit_xor {
+ T operator()(const T& x, const T& y) const;
};
template <class T=void> // C++14
-struct bit_xor : unary_function<T, bool>
-{
- bool operator()(const T& x) const;
+struct bit_not {
+ T operator()(const T& x) const;
};
+struct identity; // C++20
+
template <class Predicate>
-class unary_negate // deprecated in C++17
+class unary_negate // deprecated in C++17, removed in C++20
: public unary_function<typename Predicate::argument_type, bool>
{
public:
@@ -195,11 +181,11 @@ public:
bool operator()(const typename Predicate::argument_type& x) const;
};
-template <class Predicate> // deprecated in C++17
+template <class Predicate> // deprecated in C++17, removed in C++20
unary_negate<Predicate> not1(const Predicate& pred);
template <class Predicate>
-class binary_negate // deprecated in C++17
+class binary_negate // deprecated in C++17, removed in C++20
: public binary_function<typename Predicate::first_argument_type,
typename Predicate::second_argument_type,
bool>
@@ -210,7 +196,7 @@ public:
const typename Predicate::second_argument_type& y) const;
};
-template <class Predicate> // deprecated in C++17
+template <class Predicate> // deprecated in C++17, removed in C++20
binary_negate<Predicate> not2(const Predicate& pred);
template <class F>
@@ -501,2687 +487,43 @@ POLICY: For non-variadic implementations, the number of arguments is limited
*/
+#include <__algorithm/search.h>
#include <__config>
-#include <type_traits>
-#include <typeinfo>
+#include <__debug>
+#include <__functional/binary_function.h> // TODO: deprecate
+#include <__functional/binary_negate.h>
+#include <__functional/bind_front.h>
+#include <__functional/bind.h>
+#include <__functional/binder1st.h>
+#include <__functional/binder2nd.h>
+#include <__functional/default_searcher.h>
+#include <__functional/function.h>
+#include <__functional/hash.h>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/mem_fn.h> // TODO: deprecate
+#include <__functional/mem_fun_ref.h>
+#include <__functional/not_fn.h>
+#include <__functional/operations.h>
+#include <__functional/pointer_to_binary_function.h>
+#include <__functional/pointer_to_unary_function.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__functional/unary_function.h> // TODO: deprecate
+#include <__functional/unary_negate.h>
+#include <__functional/unwrap_ref.h>
+#include <__utility/forward.h>
+#include <concepts>
#include <exception>
#include <memory>
#include <tuple>
+#include <type_traits>
+#include <typeinfo>
#include <utility>
#include <version>
-#include <__functional_base>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x + __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS plus<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x - __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS minus<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x * __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS multiplies<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x / __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS divides<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x % __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS modulus<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x) const
- {return -__x;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS negate<void>
-{
- template <class _Tp>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_Tp&& __x) const
- _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x)))
- -> decltype (- _VSTD::forward<_Tp>(__x))
- { return - _VSTD::forward<_Tp>(__x); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x == __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS equal_to<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x != __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x > __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS greater<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-// less in <__functional_base>
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x >= __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x <= __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS less_equal<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x && __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS logical_and<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x, const _Tp& __y) const
- {return __x || __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS logical_or<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const _Tp& __x) const
- {return !__x;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS logical_not<void>
-{
- template <class _Tp>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_Tp&& __x) const
- _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x)))
- -> decltype (!_VSTD::forward<_Tp>(__x))
- { return !_VSTD::forward<_Tp>(__x); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x & __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS bit_and<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x | __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS bit_or<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-#else
-template <class _Tp>
-#endif
-struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x, const _Tp& __y) const
- {return __x ^ __y;}
-};
-
-#if _LIBCPP_STD_VER > 11
-template <>
-struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
-{
- template <class _T1, class _T2>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_T1&& __t, _T2&& __u) const
- _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
- -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
- { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); }
- typedef void is_transparent;
-};
-#endif
-
-
-#if _LIBCPP_STD_VER > 11
-template <class _Tp = void>
-struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp>
-{
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- _Tp operator()(const _Tp& __x) const
- {return ~__x;}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS bit_not<void>
-{
- template <class _Tp>
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- auto operator()(_Tp&& __x) const
- _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x)))
- -> decltype (~_VSTD::forward<_Tp>(__x))
- { return ~_VSTD::forward<_Tp>(__x); }
- typedef void is_transparent;
-};
-#endif
-
-template <class _Predicate>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
- : public unary_function<typename _Predicate::argument_type, bool>
-{
- _Predicate __pred_;
-public:
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- explicit unary_negate(const _Predicate& __pred)
- : __pred_(__pred) {}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const typename _Predicate::argument_type& __x) const
- {return !__pred_(__x);}
-};
-
-template <class _Predicate>
-_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-unary_negate<_Predicate>
-not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
-
-template <class _Predicate>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
- : public binary_function<typename _Predicate::first_argument_type,
- typename _Predicate::second_argument_type,
- bool>
-{
- _Predicate __pred_;
-public:
- _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
- binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
-
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- bool operator()(const typename _Predicate::first_argument_type& __x,
- const typename _Predicate::second_argument_type& __y) const
- {return !__pred_(__x, __y);}
-};
-
-template <class _Predicate>
-_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-binary_negate<_Predicate>
-not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
-template <class __Operation>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st
- : public unary_function<typename __Operation::second_argument_type,
- typename __Operation::result_type>
-{
-protected:
- __Operation op;
- typename __Operation::first_argument_type value;
-public:
- _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
- const typename __Operation::first_argument_type __y)
- : op(__x), value(__y) {}
- _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
- (typename __Operation::second_argument_type& __x) const
- {return op(value, __x);}
- _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
- (const typename __Operation::second_argument_type& __x) const
- {return op(value, __x);}
-};
-
-template <class __Operation, class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-binder1st<__Operation>
-bind1st(const __Operation& __op, const _Tp& __x)
- {return binder1st<__Operation>(__op, __x);}
-
-template <class __Operation>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
- : public unary_function<typename __Operation::first_argument_type,
- typename __Operation::result_type>
-{
-protected:
- __Operation op;
- typename __Operation::second_argument_type value;
-public:
- _LIBCPP_INLINE_VISIBILITY
- binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
- : op(__x), value(__y) {}
- _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
- ( typename __Operation::first_argument_type& __x) const
- {return op(__x, value);}
- _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
- (const typename __Operation::first_argument_type& __x) const
- {return op(__x, value);}
-};
-
-template <class __Operation, class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-binder2nd<__Operation>
-bind2nd(const __Operation& __op, const _Tp& __x)
- {return binder2nd<__Operation>(__op, __x);}
-
-template <class _Arg, class _Result>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
- : public unary_function<_Arg, _Result>
-{
- _Result (*__f_)(_Arg);
-public:
- _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
- : __f_(__f) {}
- _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
- {return __f_(__x);}
-};
-
-template <class _Arg, class _Result>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-pointer_to_unary_function<_Arg,_Result>
-ptr_fun(_Result (*__f)(_Arg))
- {return pointer_to_unary_function<_Arg,_Result>(__f);}
-
-template <class _Arg1, class _Arg2, class _Result>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
- : public binary_function<_Arg1, _Arg2, _Result>
-{
- _Result (*__f_)(_Arg1, _Arg2);
-public:
- _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
- : __f_(__f) {}
- _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
- {return __f_(__x, __y);}
-};
-
-template <class _Arg1, class _Arg2, class _Result>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-pointer_to_binary_function<_Arg1,_Arg2,_Result>
-ptr_fun(_Result (*__f)(_Arg1,_Arg2))
- {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
-
-template<class _Sp, class _Tp>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
- : public unary_function<_Tp*, _Sp>
-{
- _Sp (_Tp::*__p_)();
-public:
- _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
- {return (__p->*__p_)();}
-};
-
-template<class _Sp, class _Tp, class _Ap>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
- : public binary_function<_Tp*, _Ap, _Sp>
-{
- _Sp (_Tp::*__p_)(_Ap);
-public:
- _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
- {return (__p->*__p_)(__x);}
-};
-
-template<class _Sp, class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-mem_fun_t<_Sp,_Tp>
-mem_fun(_Sp (_Tp::*__f)())
- {return mem_fun_t<_Sp,_Tp>(__f);}
-
-template<class _Sp, class _Tp, class _Ap>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-mem_fun1_t<_Sp,_Tp,_Ap>
-mem_fun(_Sp (_Tp::*__f)(_Ap))
- {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
-
-template<class _Sp, class _Tp>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
- : public unary_function<_Tp, _Sp>
-{
- _Sp (_Tp::*__p_)();
-public:
- _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
- {return (__p.*__p_)();}
-};
-
-template<class _Sp, class _Tp, class _Ap>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
- : public binary_function<_Tp, _Ap, _Sp>
-{
- _Sp (_Tp::*__p_)(_Ap);
-public:
- _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
- {return (__p.*__p_)(__x);}
-};
-
-template<class _Sp, class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-mem_fun_ref_t<_Sp,_Tp>
-mem_fun_ref(_Sp (_Tp::*__f)())
- {return mem_fun_ref_t<_Sp,_Tp>(__f);}
-
-template<class _Sp, class _Tp, class _Ap>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-mem_fun1_ref_t<_Sp,_Tp,_Ap>
-mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
- {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
-
-template <class _Sp, class _Tp>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
- : public unary_function<const _Tp*, _Sp>
-{
- _Sp (_Tp::*__p_)() const;
-public:
- _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
- {return (__p->*__p_)();}
-};
-
-template <class _Sp, class _Tp, class _Ap>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
- : public binary_function<const _Tp*, _Ap, _Sp>
-{
- _Sp (_Tp::*__p_)(_Ap) const;
-public:
- _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
- {return (__p->*__p_)(__x);}
-};
-
-template <class _Sp, class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-const_mem_fun_t<_Sp,_Tp>
-mem_fun(_Sp (_Tp::*__f)() const)
- {return const_mem_fun_t<_Sp,_Tp>(__f);}
-
-template <class _Sp, class _Tp, class _Ap>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-const_mem_fun1_t<_Sp,_Tp,_Ap>
-mem_fun(_Sp (_Tp::*__f)(_Ap) const)
- {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
-
-template <class _Sp, class _Tp>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
- : public unary_function<_Tp, _Sp>
-{
- _Sp (_Tp::*__p_)() const;
-public:
- _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
- {return (__p.*__p_)();}
-};
-
-template <class _Sp, class _Tp, class _Ap>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
- : public binary_function<_Tp, _Ap, _Sp>
-{
- _Sp (_Tp::*__p_)(_Ap) const;
-public:
- _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
- : __p_(__p) {}
- _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
- {return (__p.*__p_)(__x);}
-};
-
-template <class _Sp, class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-const_mem_fun_ref_t<_Sp,_Tp>
-mem_fun_ref(_Sp (_Tp::*__f)() const)
- {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
-
-template <class _Sp, class _Tp, class _Ap>
-_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
-const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
-mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
- {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// MEMFUN
-//==============================================================================
-
-template <class _Tp>
-class __mem_fn
- : public __weak_result_type<_Tp>
-{
-public:
- // types
- typedef _Tp type;
-private:
- type __f_;
-
-public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
-
-#ifndef _LIBCPP_CXX03_LANG
- // invoke
- template <class... _ArgTypes>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename __invoke_return<type, _ArgTypes...>::type
- operator() (_ArgTypes&&... __args) const {
- return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
- }
-#else
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0>::type
- operator() (_A0& __a0) const {
- return _VSTD::__invoke(__f_, __a0);
- }
-
- template <class _A0>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return0<type, _A0 const>::type
- operator() (_A0 const& __a0) const {
- return _VSTD::__invoke(__f_, __a0);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1>::type
- operator() (_A0& __a0, _A1& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1>::type
- operator() (_A0 const& __a0, _A1& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0, _A1 const>::type
- operator() (_A0& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return1<type, _A0 const, _A1 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1) const {
- return _VSTD::__invoke(__f_, __a0, __a1);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2>::type
- operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1, _A2 const>::type
- operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type
- operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type
- operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-
- template <class _A0, class _A1, class _A2>
- _LIBCPP_INLINE_VISIBILITY
- typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type
- operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const {
- return _VSTD::__invoke(__f_, __a0, __a1, __a2);
- }
-#endif
-};
-
-template<class _Rp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-__mem_fn<_Rp _Tp::*>
-mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
-{
- return __mem_fn<_Rp _Tp::*>(__pm);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// FUNCTION
-//==============================================================================
-
-// bad_function_call
-
-class _LIBCPP_EXCEPTION_ABI bad_function_call
- : public exception
-{
-#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
-public:
- virtual ~bad_function_call() _NOEXCEPT;
-
- virtual const char* what() const _NOEXCEPT;
-#endif
-};
-
-_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
-void __throw_bad_function_call()
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw bad_function_call();
-#else
- _VSTD::abort();
-#endif
-}
-
-#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated)
-# define _LIBCPP_DEPRECATED_CXX03_FUNCTION \
- __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
-#else
-# define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */
-#endif
-
-template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
-
-namespace __function
-{
-
-template<class _Rp>
-struct __maybe_derive_from_unary_function
-{
-};
-
-template<class _Rp, class _A1>
-struct __maybe_derive_from_unary_function<_Rp(_A1)>
- : public unary_function<_A1, _Rp>
-{
-};
-
-template<class _Rp>
-struct __maybe_derive_from_binary_function
-{
-};
-
-template<class _Rp, class _A1, class _A2>
-struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
- : public binary_function<_A1, _A2, _Rp>
-{
-};
-
-template <class _Fp>
-_LIBCPP_INLINE_VISIBILITY
-bool __not_null(_Fp const&) { return true; }
-
-template <class _Fp>
-_LIBCPP_INLINE_VISIBILITY
-bool __not_null(_Fp* __ptr) { return __ptr; }
-
-template <class _Ret, class _Class>
-_LIBCPP_INLINE_VISIBILITY
-bool __not_null(_Ret _Class::*__ptr) { return __ptr; }
-
-template <class _Fp>
-_LIBCPP_INLINE_VISIBILITY
-bool __not_null(function<_Fp> const& __f) { return !!__f; }
-
-#ifdef _LIBCPP_HAS_EXTENSION_BLOCKS
-template <class _Rp, class ..._Args>
-_LIBCPP_INLINE_VISIBILITY
-bool __not_null(_Rp (^__p)(_Args...)) { return __p; }
-#endif
-
-} // namespace __function
-
-#ifndef _LIBCPP_CXX03_LANG
-
-namespace __function {
-
-// __alloc_func holds a functor and an allocator.
-
-template <class _Fp, class _Ap, class _FB> class __alloc_func;
-template <class _Fp, class _FB>
-class __default_alloc_func;
-
-template <class _Fp, class _Ap, class _Rp, class... _ArgTypes>
-class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
-{
- __compressed_pair<_Fp, _Ap> __f_;
-
- public:
- typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
- typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc;
-
- _LIBCPP_INLINE_VISIBILITY
- const _Target& __target() const { return __f_.first(); }
-
- // WIN32 APIs may define __allocator, so use __get_allocator instead.
- _LIBCPP_INLINE_VISIBILITY
- const _Alloc& __get_allocator() const { return __f_.second(); }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __alloc_func(_Target&& __f)
- : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
- _VSTD::forward_as_tuple())
- {
- }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __alloc_func(const _Target& __f, const _Alloc& __a)
- : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
- _VSTD::forward_as_tuple(__a))
- {
- }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __alloc_func(const _Target& __f, _Alloc&& __a)
- : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
- _VSTD::forward_as_tuple(_VSTD::move(__a)))
- {
- }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __alloc_func(_Target&& __f, _Alloc&& __a)
- : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
- _VSTD::forward_as_tuple(_VSTD::move(__a)))
- {
- }
-
- _LIBCPP_INLINE_VISIBILITY
- _Rp operator()(_ArgTypes&&... __arg)
- {
- typedef __invoke_void_return_wrapper<_Rp> _Invoker;
- return _Invoker::__call(__f_.first(),
- _VSTD::forward<_ArgTypes>(__arg)...);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __alloc_func* __clone() const
- {
- typedef allocator_traits<_Alloc> __alloc_traits;
- typedef
- typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
- _AA;
- _AA __a(__f_.second());
- typedef __allocator_destructor<_AA> _Dp;
- unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a));
- return __hold.release();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); }
-
- static void __destroy_and_delete(__alloc_func* __f) {
- typedef allocator_traits<_Alloc> __alloc_traits;
- typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
- _FunAlloc;
- _FunAlloc __a(__f->__get_allocator());
- __f->destroy();
- __a.deallocate(__f, 1);
- }
-};
-
-template <class _Fp, class _Rp, class... _ArgTypes>
-class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
- _Fp __f_;
-
-public:
- typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
-
- _LIBCPP_INLINE_VISIBILITY
- const _Target& __target() const { return __f_; }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __default_alloc_func(_Target&& __f) : __f_(_VSTD::move(__f)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
-
- _LIBCPP_INLINE_VISIBILITY
- _Rp operator()(_ArgTypes&&... __arg) {
- typedef __invoke_void_return_wrapper<_Rp> _Invoker;
- return _Invoker::__call(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __default_alloc_func* __clone() const {
- __builtin_new_allocator::__holder_t __hold =
- __builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
- __default_alloc_func* __res =
- ::new ((void*)__hold.get()) __default_alloc_func(__f_);
- (void)__hold.release();
- return __res;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void destroy() _NOEXCEPT { __f_.~_Target(); }
-
- static void __destroy_and_delete(__default_alloc_func* __f) {
- __f->destroy();
- __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1);
- }
-};
-
-// __base provides an abstract interface for copyable functors.
-
-template<class _Fp> class _LIBCPP_TEMPLATE_VIS __base;
-
-template<class _Rp, class ..._ArgTypes>
-class __base<_Rp(_ArgTypes...)>
-{
- __base(const __base&);
- __base& operator=(const __base&);
-public:
- _LIBCPP_INLINE_VISIBILITY __base() {}
- _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
- virtual __base* __clone() const = 0;
- virtual void __clone(__base*) const = 0;
- virtual void destroy() _NOEXCEPT = 0;
- virtual void destroy_deallocate() _NOEXCEPT = 0;
- virtual _Rp operator()(_ArgTypes&& ...) = 0;
-#ifndef _LIBCPP_NO_RTTI
- virtual const void* target(const type_info&) const _NOEXCEPT = 0;
- virtual const std::type_info& target_type() const _NOEXCEPT = 0;
-#endif // _LIBCPP_NO_RTTI
-};
-
-// __func implements __base for a given functor type.
-
-template<class _FD, class _Alloc, class _FB> class __func;
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
- : public __base<_Rp(_ArgTypes...)>
-{
- __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_;
-public:
- _LIBCPP_INLINE_VISIBILITY
- explicit __func(_Fp&& __f)
- : __f_(_VSTD::move(__f)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __func(const _Fp& __f, const _Alloc& __a)
- : __f_(__f, __a) {}
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __func(const _Fp& __f, _Alloc&& __a)
- : __f_(__f, _VSTD::move(__a)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __func(_Fp&& __f, _Alloc&& __a)
- : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
-
- virtual __base<_Rp(_ArgTypes...)>* __clone() const;
- virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
- virtual void destroy() _NOEXCEPT;
- virtual void destroy_deallocate() _NOEXCEPT;
- virtual _Rp operator()(_ArgTypes&&... __arg);
-#ifndef _LIBCPP_NO_RTTI
- virtual const void* target(const type_info&) const _NOEXCEPT;
- virtual const std::type_info& target_type() const _NOEXCEPT;
-#endif // _LIBCPP_NO_RTTI
-};
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-__base<_Rp(_ArgTypes...)>*
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
-{
- typedef allocator_traits<_Alloc> __alloc_traits;
- typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
- _Ap __a(__f_.__get_allocator());
- typedef __allocator_destructor<_Ap> _Dp;
- unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
- ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a));
- return __hold.release();
-}
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-void
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
-{
- ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
-}
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-void
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
-{
- __f_.destroy();
-}
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-void
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
-{
- typedef allocator_traits<_Alloc> __alloc_traits;
- typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
- _Ap __a(__f_.__get_allocator());
- __f_.destroy();
- __a.deallocate(this, 1);
-}
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-_Rp
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
-{
- return __f_(_VSTD::forward<_ArgTypes>(__arg)...);
-}
-
-#ifndef _LIBCPP_NO_RTTI
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-const void*
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
-{
- if (__ti == typeid(_Fp))
- return &__f_.__target();
- return nullptr;
-}
-
-template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
-const std::type_info&
-__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
-{
- return typeid(_Fp);
-}
-
-#endif // _LIBCPP_NO_RTTI
-
-// __value_func creates a value-type from a __func.
-
-template <class _Fp> class __value_func;
-
-template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
-{
- typename aligned_storage<3 * sizeof(void*)>::type __buf_;
-
- typedef __base<_Rp(_ArgTypes...)> __func;
- __func* __f_;
-
- _LIBCPP_NO_CFI static __func* __as_base(void* p)
- {
- return reinterpret_cast<__func*>(p);
- }
-
- public:
- _LIBCPP_INLINE_VISIBILITY
- __value_func() _NOEXCEPT : __f_(nullptr) {}
-
- template <class _Fp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a)
- : __f_(nullptr)
- {
- typedef allocator_traits<_Alloc> __alloc_traits;
- typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
- typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
- _FunAlloc;
-
- if (__function::__not_null(__f))
- {
- _FunAlloc __af(__a);
- if (sizeof(_Fun) <= sizeof(__buf_) &&
- is_nothrow_copy_constructible<_Fp>::value &&
- is_nothrow_copy_constructible<_FunAlloc>::value)
- {
- __f_ =
- ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af));
- }
- else
- {
- typedef __allocator_destructor<_FunAlloc> _Dp;
- unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));
- ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f), _Alloc(__a));
- __f_ = __hold.release();
- }
- }
- }
-
- template <class _Fp,
- class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type>
- _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f)
- : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {}
-
- _LIBCPP_INLINE_VISIBILITY
- __value_func(const __value_func& __f)
- {
- if (__f.__f_ == nullptr)
- __f_ = nullptr;
- else if ((void*)__f.__f_ == &__f.__buf_)
- {
- __f_ = __as_base(&__buf_);
- __f.__f_->__clone(__f_);
- }
- else
- __f_ = __f.__f_->__clone();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __value_func(__value_func&& __f) _NOEXCEPT
- {
- if (__f.__f_ == nullptr)
- __f_ = nullptr;
- else if ((void*)__f.__f_ == &__f.__buf_)
- {
- __f_ = __as_base(&__buf_);
- __f.__f_->__clone(__f_);
- }
- else
- {
- __f_ = __f.__f_;
- __f.__f_ = nullptr;
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY
- ~__value_func()
- {
- if ((void*)__f_ == &__buf_)
- __f_->destroy();
- else if (__f_)
- __f_->destroy_deallocate();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __value_func& operator=(__value_func&& __f)
- {
- *this = nullptr;
- if (__f.__f_ == nullptr)
- __f_ = nullptr;
- else if ((void*)__f.__f_ == &__f.__buf_)
- {
- __f_ = __as_base(&__buf_);
- __f.__f_->__clone(__f_);
- }
- else
- {
- __f_ = __f.__f_;
- __f.__f_ = nullptr;
- }
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __value_func& operator=(nullptr_t)
- {
- __func* __f = __f_;
- __f_ = nullptr;
- if ((void*)__f == &__buf_)
- __f->destroy();
- else if (__f)
- __f->destroy_deallocate();
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- _Rp operator()(_ArgTypes&&... __args) const
- {
- if (__f_ == nullptr)
- __throw_bad_function_call();
- return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(__value_func& __f) _NOEXCEPT
- {
- if (&__f == this)
- return;
- if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)
- {
- typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
- __func* __t = __as_base(&__tempbuf);
- __f_->__clone(__t);
- __f_->destroy();
- __f_ = nullptr;
- __f.__f_->__clone(__as_base(&__buf_));
- __f.__f_->destroy();
- __f.__f_ = nullptr;
- __f_ = __as_base(&__buf_);
- __t->__clone(__as_base(&__f.__buf_));
- __t->destroy();
- __f.__f_ = __as_base(&__f.__buf_);
- }
- else if ((void*)__f_ == &__buf_)
- {
- __f_->__clone(__as_base(&__f.__buf_));
- __f_->destroy();
- __f_ = __f.__f_;
- __f.__f_ = __as_base(&__f.__buf_);
- }
- else if ((void*)__f.__f_ == &__f.__buf_)
- {
- __f.__f_->__clone(__as_base(&__buf_));
- __f.__f_->destroy();
- __f.__f_ = __f_;
- __f_ = __as_base(&__buf_);
- }
- else
- _VSTD::swap(__f_, __f.__f_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT { return __f_ != nullptr; }
-
-#ifndef _LIBCPP_NO_RTTI
- _LIBCPP_INLINE_VISIBILITY
- const std::type_info& target_type() const _NOEXCEPT
- {
- if (__f_ == nullptr)
- return typeid(void);
- return __f_->target_type();
- }
-
- template <typename _Tp>
- _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT
- {
- if (__f_ == nullptr)
- return nullptr;
- return (const _Tp*)__f_->target(typeid(_Tp));
- }
-#endif // _LIBCPP_NO_RTTI
-};
-
-// Storage for a functor object, to be used with __policy to manage copy and
-// destruction.
-union __policy_storage
-{
- mutable char __small[sizeof(void*) * 2];
- void* __large;
-};
-
-// True if _Fun can safely be held in __policy_storage.__small.
-template <typename _Fun>
-struct __use_small_storage
- : public _VSTD::integral_constant<
- bool, sizeof(_Fun) <= sizeof(__policy_storage) &&
- _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) &&
- _VSTD::is_trivially_copy_constructible<_Fun>::value &&
- _VSTD::is_trivially_destructible<_Fun>::value> {};
-
-// Policy contains information about how to copy, destroy, and move the
-// underlying functor. You can think of it as a vtable of sorts.
-struct __policy
-{
- // Used to copy or destroy __large values. null for trivial objects.
- void* (*const __clone)(const void*);
- void (*const __destroy)(void*);
-
- // True if this is the null policy (no value).
- const bool __is_null;
-
- // The target type. May be null if RTTI is disabled.
- const std::type_info* const __type_info;
-
- // Returns a pointer to a static policy object suitable for the functor
- // type.
- template <typename _Fun>
- _LIBCPP_INLINE_VISIBILITY static const __policy* __create()
- {
- return __choose_policy<_Fun>(__use_small_storage<_Fun>());
- }
-
- _LIBCPP_INLINE_VISIBILITY
- static const __policy* __create_empty()
- {
- static const _LIBCPP_CONSTEXPR __policy __policy_ = {nullptr, nullptr,
- true,
-#ifndef _LIBCPP_NO_RTTI
- &typeid(void)
-#else
- nullptr
-#endif
- };
- return &__policy_;
- }
-
- private:
- template <typename _Fun> static void* __large_clone(const void* __s)
- {
- const _Fun* __f = static_cast<const _Fun*>(__s);
- return __f->__clone();
- }
-
- template <typename _Fun>
- static void __large_destroy(void* __s) {
- _Fun::__destroy_and_delete(static_cast<_Fun*>(__s));
- }
-
- template <typename _Fun>
- _LIBCPP_INLINE_VISIBILITY static const __policy*
- __choose_policy(/* is_small = */ false_type) {
- static const _LIBCPP_CONSTEXPR __policy __policy_ = {
- &__large_clone<_Fun>, &__large_destroy<_Fun>, false,
-#ifndef _LIBCPP_NO_RTTI
- &typeid(typename _Fun::_Target)
-#else
- nullptr
-#endif
- };
- return &__policy_;
- }
-
- template <typename _Fun>
- _LIBCPP_INLINE_VISIBILITY static const __policy*
- __choose_policy(/* is_small = */ true_type)
- {
- static const _LIBCPP_CONSTEXPR __policy __policy_ = {
- nullptr, nullptr, false,
-#ifndef _LIBCPP_NO_RTTI
- &typeid(typename _Fun::_Target)
-#else
- nullptr
-#endif
- };
- return &__policy_;
- }
-};
-
-// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is
-// faster for types that can be passed in registers.
-template <typename _Tp>
-using __fast_forward =
- typename _VSTD::conditional<_VSTD::is_scalar<_Tp>::value, _Tp, _Tp&&>::type;
-
-// __policy_invoker calls an instance of __alloc_func held in __policy_storage.
-
-template <class _Fp> struct __policy_invoker;
-
-template <class _Rp, class... _ArgTypes>
-struct __policy_invoker<_Rp(_ArgTypes...)>
-{
- typedef _Rp (*__Call)(const __policy_storage*,
- __fast_forward<_ArgTypes>...);
-
- __Call __call_;
-
- // Creates an invoker that throws bad_function_call.
- _LIBCPP_INLINE_VISIBILITY
- __policy_invoker() : __call_(&__call_empty) {}
-
- // Creates an invoker that calls the given instance of __func.
- template <typename _Fun>
- _LIBCPP_INLINE_VISIBILITY static __policy_invoker __create()
- {
- return __policy_invoker(&__call_impl<_Fun>);
- }
-
- private:
- _LIBCPP_INLINE_VISIBILITY
- explicit __policy_invoker(__Call __c) : __call_(__c) {}
-
- static _Rp __call_empty(const __policy_storage*,
- __fast_forward<_ArgTypes>...)
- {
- __throw_bad_function_call();
- }
-
- template <typename _Fun>
- static _Rp __call_impl(const __policy_storage* __buf,
- __fast_forward<_ArgTypes>... __args)
- {
- _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value
- ? &__buf->__small
- : __buf->__large);
- return (*__f)(_VSTD::forward<_ArgTypes>(__args)...);
- }
-};
-
-// __policy_func uses a __policy and __policy_invoker to create a type-erased,
-// copyable functor.
-
-template <class _Fp> class __policy_func;
-
-template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
-{
- // Inline storage for small objects.
- __policy_storage __buf_;
-
- // Calls the value stored in __buf_. This could technically be part of
- // policy, but storing it here eliminates a level of indirection inside
- // operator().
- typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker;
- __invoker __invoker_;
-
- // The policy that describes how to move / copy / destroy __buf_. Never
- // null, even if the function is empty.
- const __policy* __policy_;
-
- public:
- _LIBCPP_INLINE_VISIBILITY
- __policy_func() : __policy_(__policy::__create_empty()) {}
-
- template <class _Fp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY __policy_func(_Fp&& __f, const _Alloc& __a)
- : __policy_(__policy::__create_empty())
- {
- typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
- typedef allocator_traits<_Alloc> __alloc_traits;
- typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
- _FunAlloc;
-
- if (__function::__not_null(__f))
- {
- __invoker_ = __invoker::template __create<_Fun>();
- __policy_ = __policy::__create<_Fun>();
-
- _FunAlloc __af(__a);
- if (__use_small_storage<_Fun>())
- {
- ::new ((void*)&__buf_.__small)
- _Fun(_VSTD::move(__f), _Alloc(__af));
- }
- else
- {
- typedef __allocator_destructor<_FunAlloc> _Dp;
- unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));
- ::new ((void*)__hold.get())
- _Fun(_VSTD::move(__f), _Alloc(__af));
- __buf_.__large = __hold.release();
- }
- }
- }
-
- template <class _Fp, class = typename enable_if<!is_same<typename decay<_Fp>::type, __policy_func>::value>::type>
- _LIBCPP_INLINE_VISIBILITY explicit __policy_func(_Fp&& __f)
- : __policy_(__policy::__create_empty()) {
- typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun;
-
- if (__function::__not_null(__f)) {
- __invoker_ = __invoker::template __create<_Fun>();
- __policy_ = __policy::__create<_Fun>();
- if (__use_small_storage<_Fun>()) {
- ::new ((void*)&__buf_.__small) _Fun(_VSTD::move(__f));
- } else {
- __builtin_new_allocator::__holder_t __hold =
- __builtin_new_allocator::__allocate_type<_Fun>(1);
- __buf_.__large = ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f));
- (void)__hold.release();
- }
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __policy_func(const __policy_func& __f)
- : __buf_(__f.__buf_), __invoker_(__f.__invoker_),
- __policy_(__f.__policy_)
- {
- if (__policy_->__clone)
- __buf_.__large = __policy_->__clone(__f.__buf_.__large);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __policy_func(__policy_func&& __f)
- : __buf_(__f.__buf_), __invoker_(__f.__invoker_),
- __policy_(__f.__policy_)
- {
- if (__policy_->__destroy)
- {
- __f.__policy_ = __policy::__create_empty();
- __f.__invoker_ = __invoker();
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY
- ~__policy_func()
- {
- if (__policy_->__destroy)
- __policy_->__destroy(__buf_.__large);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __policy_func& operator=(__policy_func&& __f)
- {
- *this = nullptr;
- __buf_ = __f.__buf_;
- __invoker_ = __f.__invoker_;
- __policy_ = __f.__policy_;
- __f.__policy_ = __policy::__create_empty();
- __f.__invoker_ = __invoker();
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __policy_func& operator=(nullptr_t)
- {
- const __policy* __p = __policy_;
- __policy_ = __policy::__create_empty();
- __invoker_ = __invoker();
- if (__p->__destroy)
- __p->__destroy(__buf_.__large);
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- _Rp operator()(_ArgTypes&&... __args) const
- {
- return __invoker_.__call_(_VSTD::addressof(__buf_),
- _VSTD::forward<_ArgTypes>(__args)...);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(__policy_func& __f)
- {
- _VSTD::swap(__invoker_, __f.__invoker_);
- _VSTD::swap(__policy_, __f.__policy_);
- _VSTD::swap(__buf_, __f.__buf_);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit operator bool() const _NOEXCEPT
- {
- return !__policy_->__is_null;
- }
-
-#ifndef _LIBCPP_NO_RTTI
- _LIBCPP_INLINE_VISIBILITY
- const std::type_info& target_type() const _NOEXCEPT
- {
- return *__policy_->__type_info;
- }
-
- template <typename _Tp>
- _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT
- {
- if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info)
- return nullptr;
- if (__policy_->__clone) // Out of line storage.
- return reinterpret_cast<const _Tp*>(__buf_.__large);
- else
- return reinterpret_cast<const _Tp*>(&__buf_.__small);
- }
-#endif // _LIBCPP_NO_RTTI
-};
-
-#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
-
-extern "C" void *_Block_copy(const void *);
-extern "C" void _Block_release(const void *);
-
-template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
-class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
- : public __base<_Rp(_ArgTypes...)>
-{
- typedef _Rp1(^__block_type)(_ArgTypes1...);
- __block_type __f_;
-
-public:
- _LIBCPP_INLINE_VISIBILITY
- explicit __func(__block_type const& __f)
- : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
- { }
-
- // [TODO] add && to save on a retain
-
- _LIBCPP_INLINE_VISIBILITY
- explicit __func(__block_type __f, const _Alloc& /* unused */)
- : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
- { }
-
- virtual __base<_Rp(_ArgTypes...)>* __clone() const {
- _LIBCPP_ASSERT(false,
- "Block pointers are just pointers, so they should always fit into "
- "std::function's small buffer optimization. This function should "
- "never be invoked.");
- return nullptr;
- }
-
- virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
- ::new ((void*)__p) __func(__f_);
- }
-
- virtual void destroy() _NOEXCEPT {
- if (__f_)
- _Block_release(__f_);
- __f_ = 0;
- }
-
- virtual void destroy_deallocate() _NOEXCEPT {
- _LIBCPP_ASSERT(false,
- "Block pointers are just pointers, so they should always fit into "
- "std::function's small buffer optimization. This function should "
- "never be invoked.");
- }
-
- virtual _Rp operator()(_ArgTypes&& ... __arg) {
- return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
- }
-
-#ifndef _LIBCPP_NO_RTTI
- virtual const void* target(type_info const& __ti) const _NOEXCEPT {
- if (__ti == typeid(__func::__block_type))
- return &__f_;
- return (const void*)nullptr;
- }
-
- virtual const std::type_info& target_type() const _NOEXCEPT {
- return typeid(__func::__block_type);
- }
-#endif // _LIBCPP_NO_RTTI
-};
-
-#endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC
-
-} // __function
-
-template<class _Rp, class ..._ArgTypes>
-class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
- : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
- public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
-{
-#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
- typedef __function::__value_func<_Rp(_ArgTypes...)> __func;
-#else
- typedef __function::__policy_func<_Rp(_ArgTypes...)> __func;
-#endif
-
- __func __f_;
-
- template <class _Fp, bool = _And<
- _IsNotSame<__uncvref_t<_Fp>, function>,
- __invokable<_Fp, _ArgTypes...>
- >::value>
- struct __callable;
- template <class _Fp>
- struct __callable<_Fp, true>
- {
- static const bool value = is_void<_Rp>::value ||
- __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type,
- _Rp>::value;
- };
- template <class _Fp>
- struct __callable<_Fp, false>
- {
- static const bool value = false;
- };
-
- template <class _Fp>
- using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type;
-public:
- typedef _Rp result_type;
-
- // construct/copy/destroy:
- _LIBCPP_INLINE_VISIBILITY
- function() _NOEXCEPT { }
- _LIBCPP_INLINE_VISIBILITY
- function(nullptr_t) _NOEXCEPT {}
- function(const function&);
- function(function&&) _NOEXCEPT;
- template<class _Fp, class = _EnableIfLValueCallable<_Fp>>
- function(_Fp);
-
-#if _LIBCPP_STD_VER <= 14
- template<class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
- function(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
- template<class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
- function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {}
- template<class _Alloc>
- function(allocator_arg_t, const _Alloc&, const function&);
- template<class _Alloc>
- function(allocator_arg_t, const _Alloc&, function&&);
- template<class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>>
- function(allocator_arg_t, const _Alloc& __a, _Fp __f);
-#endif
-
- function& operator=(const function&);
- function& operator=(function&&) _NOEXCEPT;
- function& operator=(nullptr_t) _NOEXCEPT;
- template<class _Fp, class = _EnableIfLValueCallable<typename decay<_Fp>::type>>
- function& operator=(_Fp&&);
-
- ~function();
-
- // function modifiers:
- void swap(function&) _NOEXCEPT;
-
-#if _LIBCPP_STD_VER <= 14
- template<class _Fp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
- void assign(_Fp&& __f, const _Alloc& __a)
- {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);}
-#endif
-
- // function capacity:
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {
- return static_cast<bool>(__f_);
- }
-
- // deleted overloads close possible hole in the type system
- template<class _R2, class... _ArgTypes2>
- bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
- template<class _R2, class... _ArgTypes2>
- bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
-public:
- // function invocation:
- _Rp operator()(_ArgTypes...) const;
-
-#ifndef _LIBCPP_NO_RTTI
- // function target access:
- const std::type_info& target_type() const _NOEXCEPT;
- template <typename _Tp> _Tp* target() _NOEXCEPT;
- template <typename _Tp> const _Tp* target() const _NOEXCEPT;
-#endif // _LIBCPP_NO_RTTI
-};
-
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-template<class _Rp, class ..._Ap>
-function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>;
-
-template<class _Fp>
-struct __strip_signature;
-
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); };
-
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); };
-
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); };
-
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); };
-template<class _Rp, class _Gp, class ..._Ap>
-struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); };
-
-template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
-function(_Fp) -> function<_Stripped>;
-#endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES
-
-template<class _Rp, class ..._ArgTypes>
-function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {}
-
-#if _LIBCPP_STD_VER <= 14
-template<class _Rp, class ..._ArgTypes>
-template <class _Alloc>
-function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
- const function& __f) : __f_(__f.__f_) {}
-#endif
-
-template <class _Rp, class... _ArgTypes>
-function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
- : __f_(_VSTD::move(__f.__f_)) {}
-
-#if _LIBCPP_STD_VER <= 14
-template<class _Rp, class ..._ArgTypes>
-template <class _Alloc>
-function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
- function&& __f)
- : __f_(_VSTD::move(__f.__f_)) {}
-#endif
-
-template <class _Rp, class... _ArgTypes>
-template <class _Fp, class>
-function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(_VSTD::move(__f)) {}
-
-#if _LIBCPP_STD_VER <= 14
-template <class _Rp, class... _ArgTypes>
-template <class _Fp, class _Alloc, class>
-function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a,
- _Fp __f)
- : __f_(_VSTD::move(__f), __a) {}
-#endif
-
-template<class _Rp, class ..._ArgTypes>
-function<_Rp(_ArgTypes...)>&
-function<_Rp(_ArgTypes...)>::operator=(const function& __f)
-{
- function(__f).swap(*this);
- return *this;
-}
-
-template<class _Rp, class ..._ArgTypes>
-function<_Rp(_ArgTypes...)>&
-function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
-{
- __f_ = _VSTD::move(__f.__f_);
- return *this;
-}
-
-template<class _Rp, class ..._ArgTypes>
-function<_Rp(_ArgTypes...)>&
-function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
-{
- __f_ = nullptr;
- return *this;
-}
-
-template<class _Rp, class ..._ArgTypes>
-template <class _Fp, class>
-function<_Rp(_ArgTypes...)>&
-function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
-{
- function(_VSTD::forward<_Fp>(__f)).swap(*this);
- return *this;
-}
-
-template<class _Rp, class ..._ArgTypes>
-function<_Rp(_ArgTypes...)>::~function() {}
-
-template<class _Rp, class ..._ArgTypes>
-void
-function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
-{
- __f_.swap(__f.__f_);
-}
-
-template<class _Rp, class ..._ArgTypes>
-_Rp
-function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
-{
- return __f_(_VSTD::forward<_ArgTypes>(__arg)...);
-}
-
-#ifndef _LIBCPP_NO_RTTI
-
-template<class _Rp, class ..._ArgTypes>
-const std::type_info&
-function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
-{
- return __f_.target_type();
-}
-
-template<class _Rp, class ..._ArgTypes>
-template <typename _Tp>
-_Tp*
-function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
-{
- return (_Tp*)(__f_.template target<_Tp>());
-}
-
-template<class _Rp, class ..._ArgTypes>
-template <typename _Tp>
-const _Tp*
-function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
-{
- return __f_.template target<_Tp>();
-}
-
-#endif // _LIBCPP_NO_RTTI
-
-template <class _Rp, class... _ArgTypes>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
-
-template <class _Rp, class... _ArgTypes>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
-
-template <class _Rp, class... _ArgTypes>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
-
-template <class _Rp, class... _ArgTypes>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
-
-template <class _Rp, class... _ArgTypes>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
-{return __x.swap(__y);}
-
-#else // _LIBCPP_CXX03_LANG
-
-#include <__functional_03>
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// BIND
-//==============================================================================
-
-template<class _Tp> struct __is_bind_expression : public false_type {};
-template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
- : public __is_bind_expression<typename remove_cv<_Tp>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
-#endif
-
-template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
-template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
- : public __is_placeholder<typename remove_cv<_Tp>::type> {};
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp>
-_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
-#endif
-
-namespace placeholders
-{
-
-template <int _Np> struct __ph {};
-
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
-_LIBCPP_FUNC_VIS extern const __ph<1> _1;
-_LIBCPP_FUNC_VIS extern const __ph<2> _2;
-_LIBCPP_FUNC_VIS extern const __ph<3> _3;
-_LIBCPP_FUNC_VIS extern const __ph<4> _4;
-_LIBCPP_FUNC_VIS extern const __ph<5> _5;
-_LIBCPP_FUNC_VIS extern const __ph<6> _6;
-_LIBCPP_FUNC_VIS extern const __ph<7> _7;
-_LIBCPP_FUNC_VIS extern const __ph<8> _8;
-_LIBCPP_FUNC_VIS extern const __ph<9> _9;
-_LIBCPP_FUNC_VIS extern const __ph<10> _10;
-#else
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{};
-/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{};
-#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
-
-} // placeholders
-
-template<int _Np>
-struct __is_placeholder<placeholders::__ph<_Np> >
- : public integral_constant<int, _Np> {};
-
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template <class _Tp, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp&
-__mu(reference_wrapper<_Tp> __t, _Uj&)
-{
- return __t.get();
-}
-
-template <class _Ti, class ..._Uj, size_t ..._Indx>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __invoke_of<_Ti&, _Uj...>::type
-__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
-{
- return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
-}
-
-template <class _Ti, class ..._Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename _EnableIf
-<
- is_bind_expression<_Ti>::value,
- __invoke_of<_Ti&, _Uj...>
->::type
-__mu(_Ti& __ti, tuple<_Uj...>& __uj)
-{
- typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
- return _VSTD::__mu_expand(__ti, __uj, __indices());
-}
-
-template <bool IsPh, class _Ti, class _Uj>
-struct __mu_return2 {};
-
-template <class _Ti, class _Uj>
-struct __mu_return2<true, _Ti, _Uj>
-{
- typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
-};
-
-template <class _Ti, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- 0 < is_placeholder<_Ti>::value,
- typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
->::type
-__mu(_Ti&, _Uj& __uj)
-{
- const size_t _Indx = is_placeholder<_Ti>::value - 1;
- return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
-}
-
-template <class _Ti, class _Uj>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- !is_bind_expression<_Ti>::value &&
- is_placeholder<_Ti>::value == 0 &&
- !__is_reference_wrapper<_Ti>::value,
- _Ti&
->::type
-__mu(_Ti& __ti, _Uj&)
-{
- return __ti;
-}
-
-template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
- class _TupleUj>
-struct __mu_return_impl;
-
-template <bool _Invokable, class _Ti, class ..._Uj>
-struct __mu_return_invokable // false
-{
- typedef __nat type;
-};
-
-template <class _Ti, class ..._Uj>
-struct __mu_return_invokable<true, _Ti, _Uj...>
-{
- typedef typename __invoke_of<_Ti&, _Uj...>::type type;
-};
-
-template <class _Ti, class ..._Uj>
-struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
- : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
-{
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return_impl<_Ti, false, false, true, _TupleUj>
-{
- typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
- _TupleUj>::type&& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return_impl<_Ti, true, false, false, _TupleUj>
-{
- typedef typename _Ti::type& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return_impl<_Ti, false, false, false, _TupleUj>
-{
- typedef _Ti& type;
-};
-
-template <class _Ti, class _TupleUj>
-struct __mu_return
- : public __mu_return_impl<_Ti,
- __is_reference_wrapper<_Ti>::value,
- is_bind_expression<_Ti>::value,
- 0 < is_placeholder<_Ti>::value &&
- is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
- _TupleUj>
-{
-};
-
-template <class _Fp, class _BoundArgs, class _TupleUj>
-struct __is_valid_bind_return
-{
- static const bool value = false;
-};
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
-{
- static const bool value = __invokable<_Fp,
- typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
-};
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
-{
- static const bool value = __invokable<_Fp,
- typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
-};
-
-template <class _Fp, class _BoundArgs, class _TupleUj,
- bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
-struct __bind_return;
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
-{
- typedef typename __invoke_of
- <
- _Fp&,
- typename __mu_return
- <
- _BoundArgs,
- _TupleUj
- >::type...
- >::type type;
-};
-
-template <class _Fp, class ..._BoundArgs, class _TupleUj>
-struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
-{
- typedef typename __invoke_of
- <
- _Fp&,
- typename __mu_return
- <
- const _BoundArgs,
- _TupleUj
- >::type...
- >::type type;
-};
-
-template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __bind_return<_Fp, _BoundArgs, _Args>::type
-__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
- _Args&& __args)
-{
- return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...);
-}
-
-template<class _Fp, class ..._BoundArgs>
-class __bind
- : public __weak_result_type<typename decay<_Fp>::type>
-{
-protected:
- typedef typename decay<_Fp>::type _Fd;
- typedef tuple<typename decay<_BoundArgs>::type...> _Td;
-private:
- _Fd __f_;
- _Td __bound_args_;
-
- typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
-public:
- template <class _Gp, class ..._BA,
- class = typename enable_if
- <
- is_constructible<_Fd, _Gp>::value &&
- !is_same<typename remove_reference<_Gp>::type,
- __bind>::value
- >::type>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
- : __f_(_VSTD::forward<_Gp>(__f)),
- __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
- operator()(_Args&& ...__args)
- {
- return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
- tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
- }
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
- operator()(_Args&& ...__args) const
- {
- return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
- tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
- }
-};
-
-template<class _Fp, class ..._BoundArgs>
-struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-class __bind_r
- : public __bind<_Fp, _BoundArgs...>
-{
- typedef __bind<_Fp, _BoundArgs...> base;
- typedef typename base::_Fd _Fd;
- typedef typename base::_Td _Td;
-public:
- typedef _Rp result_type;
-
-
- template <class _Gp, class ..._BA,
- class = typename enable_if
- <
- is_constructible<_Fd, _Gp>::value &&
- !is_same<typename remove_reference<_Gp>::type,
- __bind_r>::value
- >::type>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
- : base(_VSTD::forward<_Gp>(__f),
- _VSTD::forward<_BA>(__bound_args)...) {}
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename enable_if
- <
- is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
- result_type>::value || is_void<_Rp>::value,
- result_type
- >::type
- operator()(_Args&& ...__args)
- {
- typedef __invoke_void_return_wrapper<_Rp> _Invoker;
- return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
- }
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename enable_if
- <
- is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
- result_type>::value || is_void<_Rp>::value,
- result_type
- >::type
- operator()(_Args&& ...__args) const
- {
- typedef __invoke_void_return_wrapper<_Rp> _Invoker;
- return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
- }
-};
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
-
-template<class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-__bind<_Fp, _BoundArgs...>
-bind(_Fp&& __f, _BoundArgs&&... __bound_args)
-{
- typedef __bind<_Fp, _BoundArgs...> type;
- return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
-}
-
-template<class _Rp, class _Fp, class ..._BoundArgs>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-__bind_r<_Rp, _Fp, _BoundArgs...>
-bind(_Fp&& __f, _BoundArgs&&... __bound_args)
-{
- typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
- return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-#if _LIBCPP_STD_VER > 14
-
-template <class _Fn, class ..._Args>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
-invoke(_Fn&& __f, _Args&&... __args)
- noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
-{
- return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
-}
-
-template <class _DecayFunc>
-class _LIBCPP_TEMPLATE_VIS __not_fn_imp {
- _DecayFunc __fd;
-
-public:
- __not_fn_imp() = delete;
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- auto operator()(_Args&& ...__args) &
- noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
- -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
- { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- auto operator()(_Args&& ...__args) &&
- noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
- -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
- { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- auto operator()(_Args&& ...__args) const&
- noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)))
- -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))
- { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); }
-
-
- template <class ..._Args>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- auto operator()(_Args&& ...__args) const&&
- noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)))
- -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))
- { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); }
-
-private:
- template <class _RawFunc,
- class = enable_if_t<!is_same<decay_t<_RawFunc>, __not_fn_imp>::value>>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- explicit __not_fn_imp(_RawFunc&& __rf)
- : __fd(_VSTD::forward<_RawFunc>(__rf)) {}
-
- template <class _RawFunc>
- friend inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&&);
-};
-
-template <class _RawFunc>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-__not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
- return __not_fn_imp<decay_t<_RawFunc>>(_VSTD::forward<_RawFunc>(__fn));
-}
-
-#endif
-
-// struct hash<T*> in <memory>
-
-template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
-pair<_ForwardIterator1, _ForwardIterator1> _LIBCPP_CONSTEXPR_AFTER_CXX11
-__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
- forward_iterator_tag, forward_iterator_tag)
-{
- if (__first2 == __last2)
- return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence
- while (true)
- {
- // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
- while (true)
- {
- if (__first1 == __last1) // return __last1 if no element matches *__first2
- return _VSTD::make_pair(__last1, __last1);
- if (__pred(*__first1, *__first2))
- break;
- ++__first1;
- }
- // *__first1 matches *__first2, now match elements after here
- _ForwardIterator1 __m1 = __first1;
- _ForwardIterator2 __m2 = __first2;
- while (true)
- {
- if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
- return _VSTD::make_pair(__first1, __m1);
- if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
- return _VSTD::make_pair(__last1, __last1);
- if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
- {
- ++__first1;
- break;
- } // else there is a match, check next elements
- }
- }
-}
-
-template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_RandomAccessIterator1, _RandomAccessIterator1>
-__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
- _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
- random_access_iterator_tag, random_access_iterator_tag)
-{
- typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
- typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
- // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
- const _D2 __len2 = __last2 - __first2;
- if (__len2 == 0)
- return _VSTD::make_pair(__first1, __first1);
- const _D1 __len1 = __last1 - __first1;
- if (__len1 < __len2)
- return _VSTD::make_pair(__last1, __last1);
- const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
-
- while (true)
- {
- while (true)
- {
- if (__first1 == __s)
- return _VSTD::make_pair(__last1, __last1);
- if (__pred(*__first1, *__first2))
- break;
- ++__first1;
- }
-
- _RandomAccessIterator1 __m1 = __first1;
- _RandomAccessIterator2 __m2 = __first2;
- while (true)
- {
- if (++__m2 == __last2)
- return _VSTD::make_pair(__first1, __first1 + __len2);
- ++__m1; // no need to check range on __m1 because __s guarantees we have enough source
- if (!__pred(*__m1, *__m2))
- {
- ++__first1;
- break;
- }
- }
- }
-}
-
-#if _LIBCPP_STD_VER > 14
-
-// default searcher
-template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
-class _LIBCPP_TYPE_VIS default_searcher {
-public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- default_searcher(_ForwardIterator __f, _ForwardIterator __l,
- _BinaryPredicate __p = _BinaryPredicate())
- : __first_(__f), __last_(__l), __pred_(__p) {}
-
- template <typename _ForwardIterator2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair<_ForwardIterator2, _ForwardIterator2>
- operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
- {
- return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
- typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
- typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
- }
-
-private:
- _ForwardIterator __first_;
- _ForwardIterator __last_;
- _BinaryPredicate __pred_;
- };
-
-#endif // _LIBCPP_STD_VER > 14
-
-#if _LIBCPP_STD_VER > 17
-template <class _Tp>
-using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
-
-template <class _Tp>
-using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
-#endif // > C++17
-
-template <class _Container, class _Predicate>
-inline typename _Container::size_type
-__libcpp_erase_if_container(_Container& __c, _Predicate __pred) {
- typename _Container::size_type __old_size = __c.size();
-
- const typename _Container::iterator __last = __c.end();
- for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) {
- if (__pred(*__iter))
- __iter = __c.erase(__iter);
- else
- ++__iter;
- }
-
- return __old_size - __c.size();
-}
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP_FUNCTIONAL
+#endif // _LIBCPP_FUNCTIONAL
diff --git a/contrib/llvm-project/libcxx/include/future b/contrib/llvm-project/libcxx/include/future
index db60ab69ecad..349e6afc43e4 100644
--- a/contrib/llvm-project/libcxx/include/future
+++ b/contrib/llvm-project/libcxx/include/future
@@ -361,13 +361,18 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
*/
-#include <__config>
#include <__availability>
-#include <system_error>
-#include <memory>
+#include <__config>
+#include <__debug>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
#include <chrono>
#include <exception>
+#include <memory>
#include <mutex>
+#include <system_error>
#include <thread>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -467,7 +472,7 @@ operator^=(launch& __x, launch __y)
__x = __x ^ __y; return __x;
}
-#endif // !_LIBCPP_HAS_NO_STRONG_ENUMS
+#endif // !_LIBCPP_HAS_NO_STRONG_ENUMS
//enum class future_status
_LIBCPP_DECLARE_STRONG_ENUM(future_status)
@@ -501,9 +506,7 @@ class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error
error_code __ec_;
public:
future_error(error_code __ec);
-#if _LIBCPP_STD_VERS > 14
- explicit future_error(future_errc _Ev) : logic_error(), __ec_(make_error_code(_Ev)) {}
-#endif
+
_LIBCPP_INLINE_VISIBILITY
const error_code& code() const _NOEXCEPT {return __ec_;}
@@ -862,7 +865,7 @@ __deferred_assoc_state<_Rp, _Fp>::__execute()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->set_value(__func_());
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -870,7 +873,7 @@ __deferred_assoc_state<_Rp, _Fp>::__execute()
{
this->set_exception(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Fp>
@@ -903,7 +906,7 @@ __deferred_assoc_state<void, _Fp>::__execute()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__func_();
this->set_value();
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -912,7 +915,7 @@ __deferred_assoc_state<void, _Fp>::__execute()
{
this->set_exception(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Rp, class _Fp>
@@ -945,7 +948,7 @@ __async_assoc_state<_Rp, _Fp>::__execute()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->set_value(__func_());
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -953,7 +956,7 @@ __async_assoc_state<_Rp, _Fp>::__execute()
{
this->set_exception(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Rp, class _Fp>
@@ -994,7 +997,7 @@ __async_assoc_state<void, _Fp>::__execute()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__func_();
this->set_value();
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1003,7 +1006,7 @@ __async_assoc_state<void, _Fp>::__execute()
{
this->set_exception(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Fp>
@@ -1953,7 +1956,7 @@ packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__p_.set_value(__f_(_VSTD::forward<_ArgTypes>(__args)...));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -1961,7 +1964,7 @@ packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args)
{
__p_.set_exception(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template<class _Rp, class ..._ArgTypes>
@@ -1975,7 +1978,7 @@ packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__p_.set_value_at_thread_exit(__f_(_VSTD::forward<_ArgTypes>(__args)...));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -1983,7 +1986,7 @@ packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args)
{
__p_.set_exception_at_thread_exit(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template<class _Rp, class ..._ArgTypes>
@@ -2082,7 +2085,7 @@ packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__f_(_VSTD::forward<_ArgTypes>(__args)...);
__p_.set_value();
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2091,7 +2094,7 @@ packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
{
__p_.set_exception(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template<class ..._ArgTypes>
@@ -2105,7 +2108,7 @@ packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__f_(_VSTD::forward<_ArgTypes>(__args)...);
__p_.set_value_at_thread_exit();
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2114,7 +2117,7 @@ packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args
{
__p_.set_exception_at_thread_exit(current_exception());
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template<class ..._ArgTypes>
@@ -2126,10 +2129,10 @@ packaged_task<void(_ArgTypes...)>::reset()
__p_ = promise<result_type>();
}
-template <class _Callable>
+template <class _Rp, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY
void
-swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT
+swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
{
__x.swap(__y);
}
@@ -2456,4 +2459,4 @@ _LIBCPP_END_NAMESPACE_STD
#endif // !_LIBCPP_HAS_NO_THREADS
-#endif // _LIBCPP_FUTURE
+#endif // _LIBCPP_FUTURE
diff --git a/contrib/llvm-project/libcxx/include/initializer_list b/contrib/llvm-project/libcxx/include/initializer_list
index 893736f57ead..ea1f234675f7 100644
--- a/contrib/llvm-project/libcxx/include/initializer_list
+++ b/contrib/llvm-project/libcxx/include/initializer_list
@@ -110,8 +110,8 @@ end(initializer_list<_Ep> __il) _NOEXCEPT
return __il.end();
}
-#endif // !defined(_LIBCPP_CXX03_LANG)
+#endif // !defined(_LIBCPP_CXX03_LANG)
} // std
-#endif // _LIBCPP_INITIALIZER_LIST
+#endif // _LIBCPP_INITIALIZER_LIST
diff --git a/contrib/llvm-project/libcxx/include/inttypes.h b/contrib/llvm-project/libcxx/include/inttypes.h
index e136b234a4ae..6b7cb2648a5e 100644
--- a/contrib/llvm-project/libcxx/include/inttypes.h
+++ b/contrib/llvm-project/libcxx/include/inttypes.h
@@ -259,4 +259,4 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
#endif // __cplusplus
-#endif // _LIBCPP_INTTYPES_H
+#endif // _LIBCPP_INTTYPES_H
diff --git a/contrib/llvm-project/libcxx/include/iomanip b/contrib/llvm-project/libcxx/include/iomanip
index 4b6418bc0b7e..47d573b5fc8a 100644
--- a/contrib/llvm-project/libcxx/include/iomanip
+++ b/contrib/llvm-project/libcxx/include/iomanip
@@ -304,7 +304,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s)
{
@@ -321,7 +321,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
{
__is.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -364,7 +364,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
@@ -380,7 +380,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
{
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __os;
}
@@ -423,7 +423,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s)
{
@@ -441,7 +441,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
{
__is.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -484,7 +484,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
@@ -501,7 +501,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
{
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __os;
}
@@ -518,7 +518,7 @@ basic_ostream<_CharT, _Traits> &
__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
_ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
{
- _VSTD::basic_string<_CharT, _Traits> __str;
+ basic_string<_CharT, _Traits> __str;
__str.push_back(__delim);
for ( ; __first != __last; ++ __first )
{
@@ -667,4 +667,4 @@ quoted (basic_string_view <_CharT, _Traits> __sv,
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_IOMANIP
+#endif // _LIBCPP_IOMANIP
diff --git a/contrib/llvm-project/libcxx/include/ios b/contrib/llvm-project/libcxx/include/ios
index 653e3a95fc7e..3128bca89999 100644
--- a/contrib/llvm-project/libcxx/include/ios
+++ b/contrib/llvm-project/libcxx/include/ios
@@ -211,8 +211,8 @@ storage-class-specifier const error_category& iostream_category() noexcept;
*/
#include <__config>
-#include <iosfwd>
#include <__locale>
+#include <iosfwd>
#include <system_error>
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
@@ -591,13 +591,6 @@ ios_base::exceptions(iostate __iostate)
clear(__rdstate_);
}
-#if defined(_LIBCPP_CXX03_LANG)
-struct _LIBCPP_TYPE_VIS __cxx03_bool {
- typedef void (__cxx03_bool::*__bool_type)();
- void __true_value() {}
-};
-#endif
-
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS basic_ios
: public ios_base
@@ -614,18 +607,8 @@ public:
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
"traits_type::char_type must be the same type as CharT");
- // __true_value will generate undefined references when linking unless
- // we give it internal linkage.
-
-#if defined(_LIBCPP_CXX03_LANG)
_LIBCPP_INLINE_VISIBILITY
- operator __cxx03_bool::__bool_type() const {
- return !fail() ? &__cxx03_bool::__true_value : nullptr;
- }
-#else
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const {return !fail();}
-#endif
+ explicit operator bool() const {return !fail();}
_LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();}
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();}
@@ -679,10 +662,8 @@ protected:
_LIBCPP_INLINE_VISIBILITY
void move(basic_ios& __rhs);
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void move(basic_ios&& __rhs) {move(__rhs);}
-#endif
_LIBCPP_INLINE_VISIBILITY
void swap(basic_ios& __rhs) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
@@ -1037,4 +1018,4 @@ defaultfloat(ios_base& __str)
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_IOS
+#endif // _LIBCPP_IOS
diff --git a/contrib/llvm-project/libcxx/include/iosfwd b/contrib/llvm-project/libcxx/include/iosfwd
index 0a0de99ff3a7..499839f7d04d 100644
--- a/contrib/llvm-project/libcxx/include/iosfwd
+++ b/contrib/llvm-project/libcxx/include/iosfwd
@@ -84,8 +84,11 @@ typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
template <class state> class fpos;
-typedef fpos<char_traits<char>::state_type> streampos;
-typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
+using streampos = fpos<char_traits<char>::state_type>;
+using wstreampos = fpos<char_traits<wchar_t>::state_type>;
+using u8streampos = fpos<char_traits<char8_t>::state_type>; // C++20
+using u16streampos = fpos<char_traits<char16_t>::state_type>;
+using u32streampos = fpos<char_traits<char32_t>::state_type>;
} // std
@@ -104,7 +107,7 @@ class _LIBCPP_TYPE_VIS ios_base;
template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
template<> struct char_traits<char>;
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
template<> struct char_traits<char8_t>;
#endif
template<> struct char_traits<char16_t>;
@@ -218,13 +221,13 @@ template <class _CharT, class _Traits>
template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
typedef fpos<mbstate_t> streampos;
typedef fpos<mbstate_t> wstreampos;
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef fpos<mbstate_t> u8streampos;
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef fpos<mbstate_t> u16streampos;
typedef fpos<mbstate_t> u32streampos;
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
#if defined(_NEWLIB_VERSION)
// On newlib, off_t is 'long int'
@@ -276,4 +279,4 @@ public:
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_IOSFWD
+#endif // _LIBCPP_IOSFWD
diff --git a/contrib/llvm-project/libcxx/include/iostream b/contrib/llvm-project/libcxx/include/iostream
index 595620b8aa62..5811fc37c85d 100644
--- a/contrib/llvm-project/libcxx/include/iostream
+++ b/contrib/llvm-project/libcxx/include/iostream
@@ -14,9 +14,9 @@
iostream synopsis
#include <ios>
-#include <streambuf>
#include <istream>
#include <ostream>
+#include <streambuf>
namespace std {
@@ -35,9 +35,9 @@ extern wostream wclog;
#include <__config>
#include <ios>
-#include <streambuf>
#include <istream>
#include <ostream>
+#include <streambuf>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -60,4 +60,4 @@ extern _LIBCPP_FUNC_VIS wostream wclog;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_IOSTREAM
+#endif // _LIBCPP_IOSTREAM
diff --git a/contrib/llvm-project/libcxx/include/istream b/contrib/llvm-project/libcxx/include/istream
index 5e984909f878..17ca68388f52 100644
--- a/contrib/llvm-project/libcxx/include/istream
+++ b/contrib/llvm-project/libcxx/include/istream
@@ -159,8 +159,9 @@ template <class Stream, class T>
*/
#include <__config>
-#include <version>
+#include <__utility/forward.h>
#include <ostream>
+#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -191,14 +192,12 @@ public:
{ this->init(__sb); }
virtual ~basic_istream();
protected:
-#ifndef _LIBCPP_CXX03_LANG
inline _LIBCPP_INLINE_VISIBILITY
basic_istream(basic_istream&& __rhs);
// 27.7.1.1.2 Assign/swap:
inline _LIBCPP_INLINE_VISIBILITY
basic_istream& operator=(basic_istream&& __rhs);
-#endif
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
void swap(basic_istream& __rhs) {
@@ -206,10 +205,8 @@ protected:
basic_ios<char_type, traits_type>::swap(__rhs);
}
-#ifndef _LIBCPP_CXX03_LANG
basic_istream (const basic_istream& __rhs) = delete;
basic_istream& operator=(const basic_istream& __rhs) = delete;
-#endif
public:
// 27.7.1.1.3 Prefix/suffix:
@@ -302,8 +299,7 @@ public:
// ~sentry() = default;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT
- operator bool() const {return __ok_;}
+ explicit operator bool() const {return __ok_;}
};
template <class _CharT, class _Traits>
@@ -333,8 +329,6 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
__is.setstate(ios_base::failbit);
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
: __gc_(__rhs.__gc_)
@@ -351,8 +345,6 @@ basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>::~basic_istream()
{
@@ -369,7 +361,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
@@ -478,7 +470,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
long __temp;
@@ -508,7 +500,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__is.setstate(__state);
}
return __is;
@@ -636,7 +628,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
return __is >> (char*)__s;
}
-#endif // _LIBCPP_STD_VER > 17
+#endif // _LIBCPP_STD_VER > 17
template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
@@ -734,7 +726,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
else
{
@@ -854,7 +846,7 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
while (true)
{
typename traits_type::int_type __i = this->rdbuf()->sgetc();
@@ -878,7 +870,7 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
__state |= ios_base::badbit;
// according to the spec, exceptions here are caught but not rethrown
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (__gc_ == 0)
__state |= ios_base::failbit;
this->setstate(__state);
@@ -898,7 +890,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
while (true)
{
typename traits_type::int_type __i = this->rdbuf()->sgetc();
@@ -938,7 +930,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
if (__n > 0)
*__s = char_type();
@@ -960,7 +952,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (__n == numeric_limits<streamsize>::max())
{
while (true)
@@ -1002,7 +994,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@@ -1021,7 +1013,7 @@ basic_istream<_CharT, _Traits>::peek()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__r = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
__state |= ios_base::eofbit;
@@ -1036,7 +1028,7 @@ basic_istream<_CharT, _Traits>::peek()
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -1054,7 +1046,7 @@ basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__gc_ = this->rdbuf()->sgetn(__s, __n);
if (__gc_ != __n)
__state |= ios_base::failbit | ios_base::eofbit;
@@ -1069,7 +1061,7 @@ basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
else
{
@@ -1091,7 +1083,7 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
streamsize __c = this->rdbuf()->in_avail();
switch (__c)
{
@@ -1118,7 +1110,7 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
else
{
@@ -1141,7 +1133,7 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1155,7 +1147,7 @@ basic_istream<_CharT, _Traits>::putback(char_type __c)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
else
{
@@ -1178,7 +1170,7 @@ basic_istream<_CharT, _Traits>::unget()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
__state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1192,7 +1184,7 @@ basic_istream<_CharT, _Traits>::unget()
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
else
{
@@ -1214,7 +1206,7 @@ basic_istream<_CharT, _Traits>::sync()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == nullptr)
return -1;
if (this->rdbuf()->pubsync() == -1)
@@ -1233,7 +1225,7 @@ basic_istream<_CharT, _Traits>::sync()
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -1251,7 +1243,7 @@ basic_istream<_CharT, _Traits>::tellg()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -1264,7 +1256,7 @@ basic_istream<_CharT, _Traits>::tellg()
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -1282,7 +1274,7 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1296,7 +1288,7 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@@ -1314,7 +1306,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -1328,7 +1320,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@@ -1345,7 +1337,7 @@ ws(basic_istream<_CharT, _Traits>& __is)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
while (true)
{
@@ -1370,25 +1362,23 @@ ws(basic_istream<_CharT, _Traits>& __is)
throw;
}
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__is.setstate(__state);
}
return __is;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Stream, class _Tp, class = void>
struct __is_istreamable : false_type { };
template <class _Stream, class _Tp>
struct __is_istreamable<_Stream, _Tp, decltype(
- _VSTD::declval<_Stream>() >> _VSTD::declval<_Tp>(), void()
+ declval<_Stream>() >> declval<_Tp>(), void()
)> : true_type { };
template <class _Stream, class _Tp, class = typename enable_if<
_And<is_base_of<ios_base, _Stream>,
- __is_istreamable<_Stream&, _Tp&&>>::value
+ __is_istreamable<_Stream&, _Tp&&> >::value
>::type>
_LIBCPP_INLINE_VISIBILITY
_Stream&& operator>>(_Stream&& __is, _Tp&& __x)
@@ -1397,8 +1387,6 @@ _Stream&& operator>>(_Stream&& __is, _Tp&& __x)
return _VSTD::move(__is);
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS basic_iostream
: public basic_istream<_CharT, _Traits>,
@@ -1420,21 +1408,18 @@ public:
virtual ~basic_iostream();
protected:
-#ifndef _LIBCPP_CXX03_LANG
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream(basic_iostream&& __rhs);
// assign/swap
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream& operator=(basic_iostream&& __rhs);
-#endif
+
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
void swap(basic_iostream& __rhs)
{ basic_istream<char_type, traits_type>::swap(__rhs); }
};
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
@@ -1449,8 +1434,6 @@ basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_iostream<_CharT, _Traits>::~basic_iostream()
{
@@ -1574,8 +1557,6 @@ getline(basic_istream<_CharT, _Traits>& __is,
return getline(__is, __str, __is.widen('\n'));
}
-#ifndef _LIBCPP_CXX03_LANG
-
template<class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
@@ -1594,8 +1575,6 @@ getline(basic_istream<_CharT, _Traits>&& __is,
return getline(__is, __str, __is.widen('\n'));
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits, size_t _Size>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
@@ -1656,4 +1635,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_ISTREAM
+#endif // _LIBCPP_ISTREAM
diff --git a/contrib/llvm-project/libcxx/include/iterator b/contrib/llvm-project/libcxx/include/iterator
index 00a3451e7a21..e0b25200bd9d 100644
--- a/contrib/llvm-project/libcxx/include/iterator
+++ b/contrib/llvm-project/libcxx/include/iterator
@@ -13,32 +13,140 @@
/*
iterator synopsis
+#include <concepts>
+
namespace std
{
+template<class> struct incrementable_traits; // since C++20
+template<class T>
+ using iter_difference_t = see below; // since C++20
+
+template<class> struct indirectly_readable_traits; // since C++20
+template<class T>
+ using iter_value_t = see below; // since C++20
template<class Iterator>
-struct iterator_traits
-{
- typedef typename Iterator::difference_type difference_type;
- typedef typename Iterator::value_type value_type;
- typedef typename Iterator::pointer pointer;
- typedef typename Iterator::reference reference;
- typedef typename Iterator::iterator_category iterator_category;
-};
+struct iterator_traits;
template<class T>
-struct iterator_traits<T*>
-{
- typedef ptrdiff_t difference_type;
- typedef T value_type;
- typedef T* pointer;
- typedef T& reference;
- typedef random_access_iterator_tag iterator_category;
-};
+ requires is_object_v<T> // since C++20
+struct iterator_traits<T*>;
+
+template<dereferenceable T>
+ using iter_reference_t = decltype(*declval<T&>());
+
+namespace ranges::inline unspecified {
+ inline constexpr unspecified iter_move = unspecified; // since C++20, nodiscard as an extension
+}}
+
+template<dereferenceable T>
+ requires ...
+using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<T&>())); // since C++20
+
+// [iterator.concepts], iterator concepts
+// [iterator.concept.readable], concept indirectly_readable
+template<class In>
+ concept indirectly_readable = see below; // since C++20
+
+template<indirectly_readable T>
+ using iter_common_reference_t =
+ common_reference_t<iter_reference_t<T>, iter_value_t<T>&>; // since C++20
+
+// [iterator.concept.writable], concept indirectly_writable
+template<class Out, class T>
+ concept indirectly_writable = see below; // since C++20
+
+// [iterator.concept.winc], concept weakly_incrementable
+template<class I>
+ concept weakly_incrementable = see below; // since C++20
+
+// [iterator.concept.inc], concept incrementable
+template<class I>
+ concept incrementable = see below; // since C++20
+
+// [iterator.concept.iterator], concept input_or_output_iterator
+ template<class I>
+ concept input_or_output_iterator = see below; // since C++20
+
+// [iterator.concept.sentinel], concept sentinel_for
+template<class S, class I>
+ concept sentinel_for = see below; // since C++20
+
+// [iterator.concept.sizedsentinel], concept sized_sentinel_for
+template<class S, class I>
+ inline constexpr bool disable_sized_sentinel_for = false;
+
+template<class S, class I>
+ concept sized_sentinel_for = see below;
+
+// [iterator.concept.input], concept input_iterator
+template<class I>
+ concept input_iterator = see below; // since C++20
+
+// [iterator.concept.output], concept output_iterator
+template<class I, class T>
+ concept output_iterator = see below; // since C++20
+
+// [iterator.concept.forward], concept forward_iterator
+template<class I>
+ concept forward_iterator = see below; // since C++20
+
+// [iterator.concept.bidir], concept bidirectional_iterator
+template<class I>
+ concept bidirectional_iterator = see below; // since C++20
+
+// [iterator.concept.random.access], concept random_access_iterator
+template<class I>
+ concept random_access_iterator = see below; // since C++20
+
+// [indirectcallable]
+// [indirectcallable.indirectinvocable]
+template<class F, class I>
+ concept indirectly_unary_invocable = see below; // since C++20
+
+template<class F, class I>
+ concept indirectly_regular_unary_invocable = see below; // since C++20
+
+template<class F, class I>
+ concept indirect_unary_predicate = see below; // since C++20
+
+template<class F, class I1, class I2>
+ concept indirect_binary_predicate = see below; // since C++20
+
+template<class F, class I1, class I2 = I1>
+ concept indirect_equivalence_relation = see below; // since C++20
+
+template<class F, class I1, class I2 = I1>
+ concept indirect_strict_weak_order = see below; // since C++20
+
+template<class F, class... Is>
+ using indirect_result_t = see below; // since C++20
+
+// [projected], projected
+template<indirectly_readable I, indirectly_regular_unary_invocable<I> Proj>
+ struct projected; // since C++20
+
+template<weakly_incrementable I, indirectly_regular_unary_invocable<I> Proj>
+ struct incrementable_traits<projected<I, Proj>>; // since C++20
+
+// [alg.req.ind.move], concept indirectly_movable
+template<class In, class Out>
+ concept indirectly_movable = see below; // since C++20
+
+template<class In, class Out>
+ concept indirectly_movable_storable = see below; // since C++20
+
+// [alg.req.ind.swap], concept indirectly_swappable
+template<class I1, class I2 = I1>
+ concept indirectly_swappable = see below; // since C++20
+
+template<input_or_output_iterator I, sentinel_for<I> S>
+ requires (!same_as<I, S> && copyable<I>)
+class common_iterator; // since C++20
template<class Category, class T, class Distance = ptrdiff_t,
class Pointer = T*, class Reference = T&>
-struct iterator
+struct iterator // deprecated in C++17
{
typedef T value_type;
typedef Distance difference_type;
@@ -69,9 +177,20 @@ template <class BidirectionalIterator> // constexpr in C++17
constexpr BidirectionalIterator prev(BidirectionalIterator x,
typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
+// [range.iter.ops], range iterator operations
+namespace ranges {
+ // [range.iter.op.advance], ranges::advance
+ template<input_or_output_iterator I>
+ constexpr void advance(I& i, iter_difference_t<I> n); // since C++20
+ template<input_or_output_iterator I, sentinel_for<I> S>
+ constexpr void advance(I& i, S bound); // since C++20
+ template<input_or_output_iterator I, sentinel_for<I> S>
+ constexpr iter_difference_t<I> advance(I& i, iter_difference_t<I> n, S bound); // since C++20
+}
+
template <class Iterator>
class reverse_iterator
- : public iterator<typename iterator_traits<Iterator>::iterator_category,
+ : public iterator<typename iterator_traits<Iterator>::iterator_category, // until C++17
typename iterator_traits<Iterator>::value_type,
typename iterator_traits<Iterator>::difference_type,
typename iterator_traits<Iterator>::pointer,
@@ -142,48 +261,53 @@ constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14
template <class Container>
class back_insert_iterator
+ : public iterator<output_iterator_tag, void, void, void, void> // until C++17
{
protected:
Container* container;
public:
typedef Container container_type;
typedef void value_type;
- typedef void difference_type;
+ typedef void difference_type; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
typedef void reference;
typedef void pointer;
- explicit back_insert_iterator(Container& x);
- back_insert_iterator& operator=(const typename Container::value_type& value);
- back_insert_iterator& operator*();
- back_insert_iterator& operator++();
- back_insert_iterator operator++(int);
+ explicit back_insert_iterator(Container& x); // constexpr in C++20
+ back_insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20
+ back_insert_iterator& operator*(); // constexpr in C++20
+ back_insert_iterator& operator++(); // constexpr in C++20
+ back_insert_iterator operator++(int); // constexpr in C++20
};
-template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
+template <class Container> back_insert_iterator<Container> back_inserter(Container& x); // constexpr in C++20
template <class Container>
class front_insert_iterator
+ : public iterator<output_iterator_tag, void, void, void, void> // until C++17
{
protected:
Container* container;
public:
typedef Container container_type;
typedef void value_type;
- typedef void difference_type;
+ typedef void difference_type; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
typedef void reference;
typedef void pointer;
- explicit front_insert_iterator(Container& x);
- front_insert_iterator& operator=(const typename Container::value_type& value);
- front_insert_iterator& operator*();
- front_insert_iterator& operator++();
- front_insert_iterator operator++(int);
+ explicit front_insert_iterator(Container& x); // constexpr in C++20
+ front_insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20
+ front_insert_iterator& operator*(); // constexpr in C++20
+ front_insert_iterator& operator++(); // constexpr in C++20
+ front_insert_iterator operator++(int); // constexpr in C++20
};
-template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
+template <class Container> front_insert_iterator<Container> front_inserter(Container& x); // constexpr in C++20
template <class Container>
class insert_iterator
+ : public iterator<output_iterator_tag, void, void, void, void> // until C++17
{
protected:
Container* container;
@@ -191,19 +315,20 @@ protected:
public:
typedef Container container_type;
typedef void value_type;
- typedef void difference_type;
+ typedef void difference_type; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
typedef void reference;
typedef void pointer;
- insert_iterator(Container& x, typename Container::iterator i);
- insert_iterator& operator=(const typename Container::value_type& value);
- insert_iterator& operator*();
- insert_iterator& operator++();
- insert_iterator& operator++(int);
+ insert_iterator(Container& x, typename Container::iterator i); // constexpr in C++20
+ insert_iterator& operator=(const typename Container::value_type& value); // constexpr in C++20
+ insert_iterator& operator*(); // constexpr in C++20
+ insert_iterator& operator++(); // constexpr in C++20
+ insert_iterator& operator++(int); // constexpr in C++20
};
template <class Container, class Iterator>
-insert_iterator<Container> inserter(Container& x, Iterator i);
+insert_iterator<Container> inserter(Container& x, Iterator i); // constexpr in C++20
template <class Iterator>
class move_iterator {
@@ -274,15 +399,31 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17
template <class Iterator> // constexpr in C++17
constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);
+// [default.sentinel], default sentinel
+struct default_sentinel_t;
+inline constexpr default_sentinel_t default_sentinel{};
+
+// [iterators.counted], counted iterators
+template<input_or_output_iterator I> class counted_iterator;
+
+template<input_iterator I>
+ requires see below
+ struct iterator_traits<counted_iterator<I>>;
template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>
class istream_iterator
- : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
+ : public iterator<input_iterator_tag, T, Distance, const T*, const T&> // until C++17
{
public:
- typedef charT char_type;
- typedef traits traits_type;
- typedef basic_istream<charT,traits> istream_type;
+ typedef input_iterator_tag iterator_category;
+ typedef T value_type;
+ typedef Distance difference_type;
+ typedef const T* pointer;
+ typedef const T& reference;
+
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef basic_istream<charT, traits> istream_type;
constexpr istream_iterator();
istream_iterator(istream_type& s);
@@ -304,9 +445,16 @@ bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
template <class T, class charT = char, class traits = char_traits<charT> >
class ostream_iterator
- : public iterator<output_iterator_tag, void, void, void ,void>
+ : public iterator<output_iterator_tag, void, void, void, void> // until C++17
{
public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+ typedef void difference_type; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
+ typedef void pointer;
+ typedef void reference;
+
typedef charT char_type;
typedef traits traits_type;
typedef basic_ostream<charT,traits> ostream_type;
@@ -324,16 +472,20 @@ public:
template<class charT, class traits = char_traits<charT> >
class istreambuf_iterator
- : public iterator<input_iterator_tag, charT,
- typename traits::off_type, unspecified,
- charT>
+ : public iterator<input_iterator_tag, charT, traits::off_type, unspecified, charT> // until C++17
{
public:
- typedef charT char_type;
- typedef traits traits_type;
- typedef typename traits::int_type int_type;
- typedef basic_streambuf<charT,traits> streambuf_type;
- typedef basic_istream<charT,traits> istream_type;
+ typedef input_iterator_tag iterator_category;
+ typedef charT value_type;
+ typedef traits::off_type difference_type;
+ typedef unspecified pointer;
+ typedef charT reference;
+
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef traits::int_type int_type;
+ typedef basic_streambuf<charT, traits> streambuf_type;
+ typedef basic_istream<charT, traits> istream_type;
istreambuf_iterator() noexcept;
istreambuf_iterator(istream_type& s) noexcept;
@@ -357,13 +509,20 @@ bool operator!=(const istreambuf_iterator<charT,traits>& a,
template <class charT, class traits = char_traits<charT> >
class ostreambuf_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
+ : public iterator<output_iterator_tag, void, void, void, void> // until C++17
{
public:
- typedef charT char_type;
- typedef traits traits_type;
- typedef basic_streambuf<charT,traits> streambuf_type;
- typedef basic_ostream<charT,traits> ostream_type;
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+ typedef void difference_type; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
+ typedef void pointer;
+ typedef void reference;
+
+ typedef charT char_type;
+ typedef traits traits_type;
+ typedef basic_streambuf<charT, traits> streambuf_type;
+ typedef basic_ostream<charT, traits> ostream_type;
ostreambuf_iterator(ostream_type& s) noexcept;
ostreambuf_iterator(streambuf_type* s) noexcept;
@@ -399,7 +558,7 @@ template <class C> constexpr auto size(const C& c) -> decltype(c.size());
template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
template <class C> constexpr auto ssize(const C& c)
- -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; // C++20
+ -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; // C++20
template <class T, ptrdiff_t> constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept; // C++20
template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
@@ -415,1608 +574,51 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
*/
#include <__config>
-#include <iosfwd> // for forward declarations of vector and string.
+#include <__debug>
#include <__functional_base>
-#include <type_traits>
+#include <__iterator/access.h>
+#include <__iterator/advance.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/common_iterator.h>
+#include <__iterator/concepts.h>
+#include <__iterator/counted_iterator.h>
+#include <__iterator/data.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/empty.h>
+#include <__iterator/erase_if_container.h>
+#include <__iterator/front_insert_iterator.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/insert_iterator.h>
+#include <__iterator/istreambuf_iterator.h>
+#include <__iterator/istream_iterator.h>
+#include <__iterator/iterator.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/move_iterator.h>
+#include <__iterator/next.h>
+#include <__iterator/ostreambuf_iterator.h>
+#include <__iterator/ostream_iterator.h>
+#include <__iterator/prev.h>
+#include <__iterator/projected.h>
+#include <__iterator/readable_traits.h>
+#include <__iterator/reverse_access.h>
+#include <__iterator/reverse_iterator.h>
+#include <__iterator/size.h>
+#include <__iterator/wrap_iter.h>
+#include <__memory/addressof.h>
+#include <__memory/pointer_traits.h>
+#include <__utility/forward.h>
+#include <compare>
+#include <concepts> // Mandated by the Standard.
#include <cstddef>
#include <initializer_list>
-#include <__memory/base.h>
+#include <type_traits>
#include <version>
-#include <__debug>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
-_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Iter>
-struct _LIBCPP_TEMPLATE_VIS iterator_traits;
-
-struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};
-struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};
-struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {};
-struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};
-struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};
-#if _LIBCPP_STD_VER > 17
-// TODO(EricWF) contiguous_iterator_tag is provided as an extension prior to
-// C++20 to allow optimizations for users providing wrapped iterator types.
-struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag: public random_access_iterator_tag { };
-#endif
-
-template <class _Iter>
-struct __iter_traits_cache {
- using type = _If<
- __is_primary_template<iterator_traits<_Iter> >::value,
- _Iter,
- iterator_traits<_Iter>
- >;
-};
-template <class _Iter>
-using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type;
-
-struct __iter_concept_concept_test {
- template <class _Iter>
- using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept;
-};
-struct __iter_concept_category_test {
- template <class _Iter>
- using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category;
-};
-struct __iter_concept_random_fallback {
- template <class _Iter>
- using _Apply = _EnableIf<
- __is_primary_template<iterator_traits<_Iter> >::value,
- random_access_iterator_tag
- >;
-};
-
-template <class _Iter, class _Tester> struct __test_iter_concept
- : _IsValidExpansion<_Tester::template _Apply, _Iter>,
- _Tester
-{
-};
-
-template <class _Iter>
-struct __iter_concept_cache {
- using type = _Or<
- __test_iter_concept<_Iter, __iter_concept_concept_test>,
- __test_iter_concept<_Iter, __iter_concept_category_test>,
- __test_iter_concept<_Iter, __iter_concept_random_fallback>
- >;
-};
-
-template <class _Iter>
-using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;
-
-
-template <class _Tp>
-struct __has_iterator_typedefs
-{
-private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
- typename __void_t<typename _Up::difference_type>::type* = 0,
- typename __void_t<typename _Up::value_type>::type* = 0,
- typename __void_t<typename _Up::reference>::type* = 0,
- typename __void_t<typename _Up::pointer>::type* = 0);
-public:
- static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1;
-};
-
-
-template <class _Tp>
-struct __has_iterator_category
-{
-private:
- struct __two {char __lx; char __lxx;};
- template <class _Up> static __two __test(...);
- template <class _Up> static char __test(typename _Up::iterator_category* = nullptr);
-public:
- static const bool value = sizeof(__test<_Tp>(nullptr)) == 1;
-};
-
-template <class _Iter, bool> struct __iterator_traits_impl {};
-
-template <class _Iter>
-struct __iterator_traits_impl<_Iter, true>
-{
- typedef typename _Iter::difference_type difference_type;
- typedef typename _Iter::value_type value_type;
- typedef typename _Iter::pointer pointer;
- typedef typename _Iter::reference reference;
- typedef typename _Iter::iterator_category iterator_category;
-};
-
-template <class _Iter, bool> struct __iterator_traits {};
-
-template <class _Iter>
-struct __iterator_traits<_Iter, true>
- : __iterator_traits_impl
- <
- _Iter,
- is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
- is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value
- >
-{};
-
-// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
-// exists. Else iterator_traits<Iterator> will be an empty class. This is a
-// conforming extension which allows some programs to compile and behave as
-// the client expects instead of failing at compile time.
-
-template <class _Iter>
-struct _LIBCPP_TEMPLATE_VIS iterator_traits
- : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {
-
- using __primary_template = iterator_traits;
-};
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
-{
- typedef ptrdiff_t difference_type;
- typedef typename remove_cv<_Tp>::type value_type;
- typedef _Tp* pointer;
- typedef _Tp& reference;
- typedef random_access_iterator_tag iterator_category;
-#if _LIBCPP_STD_VER > 17
- typedef contiguous_iterator_tag iterator_concept;
-#endif
-};
-
-template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
-struct __has_iterator_category_convertible_to
- : public integral_constant<bool, is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value>
-{};
-
-template <class _Tp, class _Up>
-struct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {};
-
-template <class _Tp>
-struct __is_cpp17_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
-
-template <class _Tp>
-struct __is_cpp17_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
-
-template <class _Tp>
-struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
-
-template <class _Tp>
-struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
-
-#if _LIBCPP_STD_VER > 17
-template <class _Tp>
-struct __is_cpp17_contiguous_iterator : public __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag> {};
-#else
-template <class _Tp>
-struct __is_cpp17_contiguous_iterator : public false_type {};
-#endif
-
-
-template <class _Tp>
-struct __is_exactly_cpp17_input_iterator
- : public integral_constant<bool,
- __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
- !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
-
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-template<class _InputIterator>
-using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
-
-template<class _InputIterator>
-using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
-
-template<class _InputIterator>
-using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;
-
-template<class _InputIterator>
-using __iter_to_alloc_type = pair<
- add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>,
- typename iterator_traits<_InputIterator>::value_type::second_type>;
-#endif
-
-template<class _Category, class _Tp, class _Distance = ptrdiff_t,
- class _Pointer = _Tp*, class _Reference = _Tp&>
-struct _LIBCPP_TEMPLATE_VIS iterator
-{
- typedef _Tp value_type;
- typedef _Distance difference_type;
- typedef _Pointer pointer;
- typedef _Reference reference;
- typedef _Category iterator_category;
-};
-
-template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-void __advance(_InputIter& __i,
- typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
-{
- for (; __n > 0; --__n)
- ++__i;
-}
-
-template <class _BiDirIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-void __advance(_BiDirIter& __i,
- typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
-{
- if (__n >= 0)
- for (; __n > 0; --__n)
- ++__i;
- else
- for (; __n < 0; ++__n)
- --__i;
-}
-
-template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-void __advance(_RandIter& __i,
- typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
-{
- __i += __n;
-}
-
-template <class _InputIter, class _Distance>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-void advance(_InputIter& __i, _Distance __orig_n)
-{
- _LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
- "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
- _IntegralSize __n = __orig_n;
- _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
-}
-
-template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename iterator_traits<_InputIter>::difference_type
-__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
-{
- typename iterator_traits<_InputIter>::difference_type __r(0);
- for (; __first != __last; ++__first)
- ++__r;
- return __r;
-}
-
-template <class _RandIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename iterator_traits<_RandIter>::difference_type
-__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
-{
- return __last - __first;
-}
-
-template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename iterator_traits<_InputIter>::difference_type
-distance(_InputIter __first, _InputIter __last)
-{
- return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
-}
-
-template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIter>::value,
- _InputIter
->::type
-next(_InputIter __x,
- typename iterator_traits<_InputIter>::difference_type __n = 1)
-{
- _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
- "Attempt to next(it, n) with negative n on a non-bidirectional iterator");
-
- _VSTD::advance(__x, __n);
- return __x;
-}
-
-template <class _InputIter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-typename enable_if
-<
- __is_cpp17_input_iterator<_InputIter>::value,
- _InputIter
->::type
-prev(_InputIter __x,
- typename iterator_traits<_InputIter>::difference_type __n = 1)
-{
- _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
- "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator");
- _VSTD::advance(__x, -__n);
- return __x;
-}
-
-
-template <class _Tp, class = void>
-struct __is_stashing_iterator : false_type {};
-
-template <class _Tp>
-struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type>
- : true_type {};
-
-template <class _Iter>
-class _LIBCPP_TEMPLATE_VIS reverse_iterator
- : public iterator<typename iterator_traits<_Iter>::iterator_category,
- typename iterator_traits<_Iter>::value_type,
- typename iterator_traits<_Iter>::difference_type,
- typename iterator_traits<_Iter>::pointer,
- typename iterator_traits<_Iter>::reference>
-{
-private:
- /*mutable*/ _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
-
- static_assert(!__is_stashing_iterator<_Iter>::value,
- "The specified iterator type cannot be used with reverse_iterator; "
- "Using stashing iterators with reverse_iterator causes undefined behavior");
-
-protected:
- _Iter current;
-public:
- typedef _Iter iterator_type;
- typedef typename iterator_traits<_Iter>::difference_type difference_type;
- typedef typename iterator_traits<_Iter>::reference reference;
- typedef typename iterator_traits<_Iter>::pointer pointer;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator() : __t(), current() {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {}
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator& operator=(const reverse_iterator<_Up>& __u)
- { __t = current = __u.base(); return *this; }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- _Iter base() const {return current;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator*() const {_Iter __tmp = current; return *--__tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- pointer operator->() const {return _VSTD::addressof(operator*());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator& operator++() {--current; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator& operator--() {++current; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](difference_type __n) const {return *(*this + __n);}
-};
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __x.base() == __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __x.base() > __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __x.base() != __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __x.base() < __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __x.base() <= __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __x.base() >= __y.base();
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
--> decltype(__y.base() - __x.base())
-{
- return __y.base() - __x.base();
-}
-#else
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename reverse_iterator<_Iter1>::difference_type
-operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-{
- return __y.base() - __x.base();
-}
-#endif
-
-template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-reverse_iterator<_Iter>
-operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
-{
- return reverse_iterator<_Iter>(__x.base() - __n);
-}
-
-#if _LIBCPP_STD_VER > 11
-template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
-{
- return reverse_iterator<_Iter>(__i);
-}
-#endif
-
-template <class _Container>
-class _LIBCPP_TEMPLATE_VIS back_insert_iterator
- : public iterator<output_iterator_tag,
- void,
- void,
- void,
- void>
-{
-protected:
- _Container* container;
-public:
- typedef _Container container_type;
-
- _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
- _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
- {container->push_back(__value_); return *this;}
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_)
- {container->push_back(_VSTD::move(__value_)); return *this;}
-#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*() {return *this;}
- _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;}
- _LIBCPP_INLINE_VISIBILITY back_insert_iterator operator++(int) {return *this;}
-};
-
-template <class _Container>
-inline _LIBCPP_INLINE_VISIBILITY
-back_insert_iterator<_Container>
-back_inserter(_Container& __x)
-{
- return back_insert_iterator<_Container>(__x);
-}
-
-template <class _Container>
-class _LIBCPP_TEMPLATE_VIS front_insert_iterator
- : public iterator<output_iterator_tag,
- void,
- void,
- void,
- void>
-{
-protected:
- _Container* container;
-public:
- typedef _Container container_type;
-
- _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
- _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
- {container->push_front(__value_); return *this;}
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_)
- {container->push_front(_VSTD::move(__value_)); return *this;}
-#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*() {return *this;}
- _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++() {return *this;}
- _LIBCPP_INLINE_VISIBILITY front_insert_iterator operator++(int) {return *this;}
-};
-
-template <class _Container>
-inline _LIBCPP_INLINE_VISIBILITY
-front_insert_iterator<_Container>
-front_inserter(_Container& __x)
-{
- return front_insert_iterator<_Container>(__x);
-}
-
-template <class _Container>
-class _LIBCPP_TEMPLATE_VIS insert_iterator
- : public iterator<output_iterator_tag,
- void,
- void,
- void,
- void>
-{
-protected:
- _Container* container;
- typename _Container::iterator iter;
-public:
- typedef _Container container_type;
-
- _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
- : container(_VSTD::addressof(__x)), iter(__i) {}
- _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
- {iter = container->insert(iter, __value_); ++iter; return *this;}
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_)
- {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
-#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*() {return *this;}
- _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++() {return *this;}
- _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++(int) {return *this;}
-};
-
-template <class _Container>
-inline _LIBCPP_INLINE_VISIBILITY
-insert_iterator<_Container>
-inserter(_Container& __x, typename _Container::iterator __i)
-{
- return insert_iterator<_Container>(__x, __i);
-}
-
-template <class _Tp, class _CharT = char,
- class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
-class _LIBCPP_TEMPLATE_VIS istream_iterator
- : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
-{
-public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef basic_istream<_CharT,_Traits> istream_type;
-private:
- istream_type* __in_stream_;
- _Tp __value_;
-public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {}
- _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s))
- {
- if (!(*__in_stream_ >> __value_))
- __in_stream_ = nullptr;
- }
-
- _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
- _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));}
- _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
- {
- if (!(*__in_stream_ >> __value_))
- __in_stream_ = nullptr;
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)
- {istream_iterator __t(*this); ++(*this); return __t;}
-
- template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
- friend _LIBCPP_INLINE_VISIBILITY
- bool
- operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
- const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
-
- template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
- friend _LIBCPP_INLINE_VISIBILITY
- bool
- operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
- const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
-};
-
-template <class _Tp, class _CharT, class _Traits, class _Distance>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
- const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
-{
- return __x.__in_stream_ == __y.__in_stream_;
-}
-
-template <class _Tp, class _CharT, class _Traits, class _Distance>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
- const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
-{
- return !(__x == __y);
-}
-
-template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
-class _LIBCPP_TEMPLATE_VIS ostream_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
-{
-public:
- typedef output_iterator_tag iterator_category;
- typedef void value_type;
-#if _LIBCPP_STD_VER > 17
- typedef std::ptrdiff_t difference_type;
-#else
- typedef void difference_type;
-#endif
- typedef void pointer;
- typedef void reference;
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef basic_ostream<_CharT, _Traits> ostream_type;
-
-private:
- ostream_type* __out_stream_;
- const char_type* __delim_;
-public:
- _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT
- : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {}
- _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT
- : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {}
- _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
- {
- *__out_stream_ << __value_;
- if (__delim_)
- *__out_stream_ << __delim_;
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;}
- _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;}
- _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;}
-};
-
-template<class _CharT, class _Traits>
-class _LIBCPP_TEMPLATE_VIS istreambuf_iterator
- : public iterator<input_iterator_tag, _CharT,
- typename _Traits::off_type, _CharT*,
- _CharT>
-{
-public:
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef typename _Traits::int_type int_type;
- typedef basic_streambuf<_CharT,_Traits> streambuf_type;
- typedef basic_istream<_CharT,_Traits> istream_type;
-private:
- mutable streambuf_type* __sbuf_;
-
- class __proxy
- {
- char_type __keep_;
- streambuf_type* __sbuf_;
- _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)
- : __keep_(__c), __sbuf_(__s) {}
- friend class istreambuf_iterator;
- public:
- _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;}
- };
-
- _LIBCPP_INLINE_VISIBILITY
- bool __test_for_eof() const
- {
- if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
- __sbuf_ = nullptr;
- return __sbuf_ == nullptr;
- }
-public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {}
- _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
- : __sbuf_(__s.rdbuf()) {}
- _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
- : __sbuf_(__s) {}
- _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT
- : __sbuf_(__p.__sbuf_) {}
-
- _LIBCPP_INLINE_VISIBILITY char_type operator*() const
- {return static_cast<char_type>(__sbuf_->sgetc());}
- _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++()
- {
- __sbuf_->sbumpc();
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY __proxy operator++(int)
- {
- return __proxy(__sbuf_->sbumpc(), __sbuf_);
- }
-
- _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
- {return __test_for_eof() == __b.__test_for_eof();}
-};
-
-template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
- const istreambuf_iterator<_CharT,_Traits>& __b)
- {return __a.equal(__b);}
-
-template <class _CharT, class _Traits>
-inline _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
- const istreambuf_iterator<_CharT,_Traits>& __b)
- {return !__a.equal(__b);}
-
-template <class _CharT, class _Traits>
-class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator
- : public iterator<output_iterator_tag, void, void, void, void>
-{
-public:
- typedef output_iterator_tag iterator_category;
- typedef void value_type;
-#if _LIBCPP_STD_VER > 17
- typedef std::ptrdiff_t difference_type;
-#else
- typedef void difference_type;
-#endif
- typedef void pointer;
- typedef void reference;
- typedef _CharT char_type;
- typedef _Traits traits_type;
- typedef basic_streambuf<_CharT, _Traits> streambuf_type;
- typedef basic_ostream<_CharT, _Traits> ostream_type;
-
-private:
- streambuf_type* __sbuf_;
-public:
- _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT
- : __sbuf_(__s.rdbuf()) {}
- _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT
- : __sbuf_(__s) {}
- _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
- {
- if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
- __sbuf_ = nullptr;
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;}
- _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;}
- _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
- _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;}
-
- template <class _Ch, class _Tr>
- friend
- _LIBCPP_HIDDEN
- ostreambuf_iterator<_Ch, _Tr>
- __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
- const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
- ios_base& __iob, _Ch __fl);
-};
-
-template <class _Iter>
-class _LIBCPP_TEMPLATE_VIS move_iterator
-{
-private:
- _Iter __i;
-public:
- typedef _Iter iterator_type;
- typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
- typedef typename iterator_traits<iterator_type>::value_type value_type;
- typedef typename iterator_traits<iterator_type>::difference_type difference_type;
- typedef iterator_type pointer;
-#ifndef _LIBCPP_CXX03_LANG
- typedef typename iterator_traits<iterator_type>::reference __reference;
- typedef typename conditional<
- is_reference<__reference>::value,
- typename remove_reference<__reference>::type&&,
- __reference
- >::type reference;
-#else
- typedef typename iterator_traits<iterator_type>::reference reference;
-#endif
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator() : __i() {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- explicit move_iterator(_Iter __x) : __i(__x) {}
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator*() const { return static_cast<reference>(*__i); }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- pointer operator->() const { return __i;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator& operator++() {++__i; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator& operator--() {--__i; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator& operator+=(difference_type __n) {__i += __n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); }
-};
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() == __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() < __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() != __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() > __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() >= __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-bool
-operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() <= __y.base();
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
--> decltype(__x.base() - __y.base())
-{
- return __x.base() - __y.base();
-}
-#else
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY
-typename move_iterator<_Iter1>::difference_type
-operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-{
- return __x.base() - __y.base();
-}
-#endif
-
-template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-move_iterator<_Iter>
-operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
-{
- return move_iterator<_Iter>(__x.base() + __n);
-}
-
-template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-move_iterator<_Iter>
-make_move_iterator(_Iter __i)
-{
- return move_iterator<_Iter>(__i);
-}
-
-// __wrap_iter
-
-template <class _Iter> class __wrap_iter;
-
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-auto
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
--> decltype(__x.base() - __y.base());
-#else
-template <class _Iter1, class _Iter2>
-_LIBCPP_INLINE_VISIBILITY
-typename __wrap_iter<_Iter1>::difference_type
-operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-#endif
-
-template <class _Iter>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-__wrap_iter<_Iter>
-operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT;
-
-template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy(_Ip, _Ip, _Op);
-template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 copy_backward(_B1, _B1, _B2);
-template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move(_Ip, _Ip, _Op);
-template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 move_backward(_B1, _B1, _B2);
-
-#if _LIBCPP_DEBUG_LEVEL < 2
-
-template <class _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_trivially_copy_assignable<_Tp>::value,
- _Tp*
->::type
-__unwrap_iter(__wrap_iter<_Tp*>);
-
-#else
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_trivially_copy_assignable<_Tp>::value,
- __wrap_iter<_Tp*>
->::type
-__unwrap_iter(__wrap_iter<_Tp*> __i);
-
-#endif
-
-template <class _Iter>
-class __wrap_iter
-{
-public:
- typedef _Iter iterator_type;
- typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
- typedef typename iterator_traits<iterator_type>::value_type value_type;
- typedef typename iterator_traits<iterator_type>::difference_type difference_type;
- typedef typename iterator_traits<iterator_type>::pointer pointer;
- typedef typename iterator_traits<iterator_type>::reference reference;
-private:
- iterator_type __i;
-public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT
-#if _LIBCPP_STD_VER > 11
- : __i{}
-#endif
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__insert_i(this);
-#endif
- }
- template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
- __wrap_iter(const __wrap_iter<_Up>& __u,
- typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
- : __i(__u.base())
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- __get_db()->__iterator_copy(this, &__u);
-#endif
- }
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
- __wrap_iter(const __wrap_iter& __x)
- : __i(__x.base())
- {
- __get_db()->__iterator_copy(this, &__x);
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
- __wrap_iter& operator=(const __wrap_iter& __x)
- {
- if (this != &__x)
- {
- __get_db()->__iterator_copy(this, &__x);
- __i = __x.__i;
- }
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
- ~__wrap_iter()
- {
- __get_db()->__erase_i(this);
- }
-#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to dereference a non-dereferenceable iterator");
-#endif
- return *__i;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to dereference a non-dereferenceable iterator");
-#endif
- return (pointer)_VSTD::addressof(*__i);
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable iterator");
-#endif
- ++__i;
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT
- {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
- "Attempted to decrement non-decrementable iterator");
-#endif
- --__i;
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT
- {__wrap_iter __tmp(*this); --(*this); return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
- {__wrap_iter __w(*this); __w += __n; return __w;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
- "Attempted to add/subtract iterator outside of valid range");
-#endif
- __i += __n;
- return *this;
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT
- {return *this + (-__n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
- {*this += -__n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT
- {
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
- "Attempted to subscript iterator outside of valid range");
-#endif
- return __i[__n];
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;}
-
-private:
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
- {
- __get_db()->__insert_ic(this, __p);
- }
-#else
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
-#endif
-
- template <class _Up> friend class __wrap_iter;
- template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
- template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
- template <class _Tp, size_t> friend class _LIBCPP_TEMPLATE_VIS span;
-
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- bool
- operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- bool
- operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- bool
- operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- bool
- operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- bool
- operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- bool
- operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- auto
- operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
- -> decltype(__x.base() - __y.base());
-#else
- template <class _Iter1, class _Iter2>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- typename __wrap_iter<_Iter1>::difference_type
- operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
-#endif
-
- template <class _Iter1>
- _LIBCPP_CONSTEXPR_IF_NODEBUG friend
- __wrap_iter<_Iter1>
- operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT;
-
- template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op copy(_Ip, _Ip, _Op);
- template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 copy_backward(_B1, _B1, _B2);
- template <class _Ip, class _Op> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _Op move(_Ip, _Ip, _Op);
- template <class _B1, class _B2> friend _LIBCPP_CONSTEXPR_AFTER_CXX17 _B2 move_backward(_B1, _B1, _B2);
-
-#if _LIBCPP_DEBUG_LEVEL < 2
- template <class _Tp>
- _LIBCPP_CONSTEXPR friend
- typename enable_if
- <
- is_trivially_copy_assignable<_Tp>::value,
- _Tp*
- >::type
- __unwrap_iter(__wrap_iter<_Tp*>);
-#else
- template <class _Tp>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR friend
- typename enable_if
- <
- is_trivially_copy_assignable<_Tp>::value,
- __wrap_iter<_Tp*>
- >::type
- __unwrap_iter(__wrap_iter<_Tp*> __i);
-#endif
-};
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
- return __x.base() == __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
- "Attempted to compare incomparable iterators");
-#endif
- return __x.base() < __y.base();
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
- return !(__x == __y);
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
- return __y < __x;
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
- return !(__x < __y);
-}
-
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
- return !(__y < __x);
-}
-
-template <class _Iter1>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
-{
- return !(__x == __y);
-}
-
-template <class _Iter1>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
-{
- return __y < __x;
-}
-
-template <class _Iter1>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
-{
- return !(__x < __y);
-}
-
-template <class _Iter1>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-bool
-operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
-{
- return !(__y < __x);
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-auto
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
--> decltype(__x.base() - __y.base())
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
- "Attempted to subtract incompatible iterators");
-#endif
- return __x.base() - __y.base();
-}
-#else
-template <class _Iter1, class _Iter2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-typename __wrap_iter<_Iter1>::difference_type
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-{
-#if _LIBCPP_DEBUG_LEVEL == 2
- _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
- "Attempted to subtract incompatible iterators");
-#endif
- return __x.base() - __y.base();
-}
-#endif
-
-template <class _Iter>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
-__wrap_iter<_Iter>
-operator+(typename __wrap_iter<_Iter>::difference_type __n,
- __wrap_iter<_Iter> __x) _NOEXCEPT
-{
- __x += __n;
- return __x;
-}
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator
- : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
- : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator<reverse_iterator<_Iter> >
- : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
-
-template <class _Iter>
-struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
- : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
-
-
-template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp*
-begin(_Tp (&__array)[_Np])
-{
- return __array;
-}
-
-template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp*
-end(_Tp (&__array)[_Np])
-{
- return __array + _Np;
-}
-
-#if !defined(_LIBCPP_CXX03_LANG)
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-begin(_Cp& __c) -> decltype(__c.begin())
-{
- return __c.begin();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-begin(const _Cp& __c) -> decltype(__c.begin())
-{
- return __c.begin();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-end(_Cp& __c) -> decltype(__c.end())
-{
- return __c.end();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto
-end(const _Cp& __c) -> decltype(__c.end())
-{
- return __c.end();
-}
-
-#if _LIBCPP_STD_VER > 11
-
-template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
-{
- return reverse_iterator<_Tp*>(__array + _Np);
-}
-
-template <class _Tp, size_t _Np>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
-{
- return reverse_iterator<_Tp*>(__array);
-}
-
-template <class _Ep>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
-{
- return reverse_iterator<const _Ep*>(__il.end());
-}
-
-template <class _Ep>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
-{
- return reverse_iterator<const _Ep*>(__il.begin());
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
-{
- return _VSTD::begin(__c);
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
-{
- return _VSTD::end(__c);
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
-{
- return __c.rbegin();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
-{
- return __c.rbegin();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto rend(_Cp& __c) -> decltype(__c.rend())
-{
- return __c.rend();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto rend(const _Cp& __c) -> decltype(__c.rend())
-{
- return __c.rend();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
-{
- return _VSTD::rbegin(__c);
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
-{
- return _VSTD::rend(__c);
-}
-
-#endif
-
-
-#else // defined(_LIBCPP_CXX03_LANG)
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY
-typename _Cp::iterator
-begin(_Cp& __c)
-{
- return __c.begin();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY
-typename _Cp::const_iterator
-begin(const _Cp& __c)
-{
- return __c.begin();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY
-typename _Cp::iterator
-end(_Cp& __c)
-{
- return __c.end();
-}
-
-template <class _Cp>
-_LIBCPP_INLINE_VISIBILITY
-typename _Cp::const_iterator
-end(const _Cp& __c)
-{
- return __c.end();
-}
-
-#endif // !defined(_LIBCPP_CXX03_LANG)
-
-#if _LIBCPP_STD_VER > 14
-
-// #if _LIBCPP_STD_VER > 11
-// template <>
-// struct _LIBCPP_TEMPLATE_VIS plus<void>
-// {
-// template <class _T1, class _T2>
-// _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-// auto operator()(_T1&& __t, _T2&& __u) const
-// _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
-// -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
-// { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
-// typedef void is_transparent;
-// };
-// #endif
-
-template <class _Cont>
-_LIBCPP_INLINE_VISIBILITY
-constexpr auto size(const _Cont& __c)
-_NOEXCEPT_(noexcept(__c.size()))
--> decltype (__c.size())
-{ return __c.size(); }
-
-template <class _Tp, size_t _Sz>
-_LIBCPP_INLINE_VISIBILITY
-constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
-
-#if _LIBCPP_STD_VER > 17
-template <class _Cont>
-_LIBCPP_INLINE_VISIBILITY
-constexpr auto ssize(const _Cont& __c)
-_NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size())))
--> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>
-{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); }
-
-template <class _Tp, ptrdiff_t _Sz>
-_LIBCPP_INLINE_VISIBILITY
-constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; }
-#endif
-
-template <class _Cont>
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-constexpr auto empty(const _Cont& __c)
-_NOEXCEPT_(noexcept(__c.empty()))
--> decltype (__c.empty())
-{ return __c.empty(); }
-
-template <class _Tp, size_t _Sz>
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
-
-template <class _Ep>
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
-constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
-
-template <class _Cont> constexpr
-_LIBCPP_INLINE_VISIBILITY
-auto data(_Cont& __c)
-_NOEXCEPT_(noexcept(__c.data()))
--> decltype (__c.data())
-{ return __c.data(); }
-
-template <class _Cont> constexpr
-_LIBCPP_INLINE_VISIBILITY
-auto data(const _Cont& __c)
-_NOEXCEPT_(noexcept(__c.data()))
--> decltype (__c.data())
-{ return __c.data(); }
-
-template <class _Tp, size_t _Sz>
-_LIBCPP_INLINE_VISIBILITY
-constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
-
-template <class _Ep>
-_LIBCPP_INLINE_VISIBILITY
-constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
-#endif
-
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP_ITERATOR
+#endif // _LIBCPP_ITERATOR
diff --git a/contrib/llvm-project/libcxx/include/latch b/contrib/llvm-project/libcxx/include/latch
index a894f8cafd1c..10ae5721fbec 100644
--- a/contrib/llvm-project/libcxx/include/latch
+++ b/contrib/llvm-project/libcxx/include/latch
@@ -40,8 +40,8 @@ namespace std
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <atomic>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/contrib/llvm-project/libcxx/include/limits b/contrib/llvm-project/libcxx/include/limits
index 8f97cd10a8b1..a6d517852493 100644
--- a/contrib/llvm-project/libcxx/include/limits
+++ b/contrib/llvm-project/libcxx/include/limits
@@ -815,4 +815,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_LIMITS
+#endif // _LIBCPP_LIMITS
diff --git a/contrib/llvm-project/libcxx/include/limits.h b/contrib/llvm-project/libcxx/include/limits.h
index 4a212f8f35a8..938f8875bc54 100644
--- a/contrib/llvm-project/libcxx/include/limits.h
+++ b/contrib/llvm-project/libcxx/include/limits.h
@@ -61,4 +61,4 @@ Macros:
#include_next <limits.h>
#endif // __GNUC__
-#endif // _LIBCPP_LIMITS_H
+#endif // _LIBCPP_LIMITS_H
diff --git a/contrib/llvm-project/libcxx/include/list b/contrib/llvm-project/libcxx/include/list
index a18514d74eaf..23da5fcfc92d 100644
--- a/contrib/llvm-project/libcxx/include/list
+++ b/contrib/llvm-project/libcxx/include/list
@@ -181,17 +181,16 @@ template <class T, class Allocator, class Predicate>
*/
#include <__config>
-
-#include <memory>
-#include <limits>
+#include <__debug>
+#include <__utility/forward.h>
+#include <algorithm>
#include <initializer_list>
#include <iterator>
-#include <algorithm>
+#include <limits>
+#include <memory>
#include <type_traits>
#include <version>
-#include <__debug>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -267,7 +266,7 @@ struct __list_node_base
};
template <class _Tp, class _VoidPtr>
-struct __list_node
+struct _LIBCPP_STANDALONE_DEBUG __list_node
: public __list_node_base<_Tp, _VoidPtr>
{
_Tp __value_;
@@ -351,7 +350,7 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
@@ -377,7 +376,7 @@ public:
{
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable list::iterator");
+ "Attempted to increment a non-incrementable list::iterator");
#endif
__ptr_ = __ptr_->__next_;
return *this;
@@ -390,7 +389,7 @@ public:
{
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
- "Attempted to decrement non-decrementable list::iterator");
+ "Attempted to decrement a non-decrementable list::iterator");
#endif
__ptr_ = __ptr_->__prev_;
return *this;
@@ -479,7 +478,7 @@ public:
return *this;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reference operator*() const
{
@@ -504,7 +503,7 @@ public:
{
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
- "Attempted to increment non-incrementable list::const_iterator");
+ "Attempted to increment a non-incrementable list::const_iterator");
#endif
__ptr_ = __ptr_->__next_;
return *this;
@@ -517,7 +516,7 @@ public:
{
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
- "Attempted to decrement non-decrementable list::const_iterator");
+ "Attempted to decrement a non-decrementable list::const_iterator");
#endif
__ptr_ = __ptr_->__prev_;
return *this;
@@ -895,7 +894,7 @@ public:
typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0);
list(const list& __c);
- list(const list& __c, const allocator_type& __a);
+ list(const list& __c, const __identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
list& operator=(const list& __c);
#ifndef _LIBCPP_CXX03_LANG
@@ -906,7 +905,7 @@ public:
list(list&& __c)
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
_LIBCPP_INLINE_VISIBILITY
- list(list&& __c, const allocator_type& __a);
+ list(list&& __c, const __identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
list& operator=(list&& __c)
_NOEXCEPT_(
@@ -920,7 +919,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _InpIter>
void assign(_InpIter __f, _InpIter __l,
@@ -1023,7 +1022,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __p, initializer_list<value_type> __il)
{return insert(__p, __il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
void push_front(const value_type& __x);
void push_back(const value_type& __x);
@@ -1124,7 +1123,7 @@ public:
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
_LIBCPP_INLINE_VISIBILITY
@@ -1144,18 +1143,18 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
list(_InputIterator, _InputIterator)
- -> list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> list<__iter_value_type<_InputIterator>, _Alloc>;
template<class _InputIterator,
class _Alloc,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
list(_InputIterator, _InputIterator, _Alloc)
- -> list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> list<__iter_value_type<_InputIterator>, _Alloc>;
#endif
// Link in nodes [__f, __l] just prior to __p
@@ -1288,7 +1287,7 @@ list<_Tp, _Alloc>::list(const list& __c)
}
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a)
+list<_Tp, _Alloc>::list(const list& __c, const __identity_t<allocator_type>& __a)
: base(__a)
{
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -1335,7 +1334,7 @@ inline list<_Tp, _Alloc>::list(list&& __c)
template <class _Tp, class _Alloc>
inline
-list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
+list<_Tp, _Alloc>::list(list&& __c, const __identity_t<allocator_type>& __a)
: base(__a)
{
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -1386,7 +1385,7 @@ list<_Tp, _Alloc>::__move_assign(list& __c, true_type)
splice(end(), __c);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
inline
@@ -1495,7 +1494,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (--__n; __n != 0; --__n, ++__e, ++__ds)
{
__hold.reset(__node_alloc_traits::allocate(__na, 1));
@@ -1523,7 +1522,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
}
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
@@ -1561,7 +1560,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (++__f; __f != __l; ++__f, (void) ++__e, (void) ++__ds)
{
__hold.reset(__node_alloc_traits::allocate(__na, 1));
@@ -1589,7 +1588,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
}
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
@@ -1737,7 +1736,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
#endif
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
void
@@ -1772,7 +1771,7 @@ template <class _Tp, class _Alloc>
void
list<_Tp, _Alloc>::pop_back()
{
- _LIBCPP_ASSERT(!empty(), "list::pop_back() called with empty list");
+ _LIBCPP_ASSERT(!empty(), "list::pop_back() called on an empty list");
__node_allocator& __na = base::__node_alloc();
__link_pointer __n = base::__end_.__prev_;
base::__unlink_nodes(__n, __n);
@@ -1909,7 +1908,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (--__n; __n != 0; --__n, ++__e, ++__ds)
{
__hold.reset(__node_alloc_traits::allocate(__na, 1));
@@ -1937,7 +1936,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
}
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__link_nodes_at_back(__r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
@@ -1967,7 +1966,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (--__n; __n != 0; --__n, ++__e, ++__ds)
{
__hold.reset(__node_alloc_traits::allocate(__na, 1));
@@ -1995,7 +1994,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
}
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
@@ -2049,14 +2048,14 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
{
#if _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
- "list::splice(iterator, list, iterator) called with first iterator not"
- " referring to this list");
+ "list::splice(iterator, list, iterator) called with the first iterator"
+ " not referring to this list");
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__i) == &__c,
- "list::splice(iterator, list, iterator) called with second iterator not"
- " referring to list argument");
+ "list::splice(iterator, list, iterator) called with the second iterator"
+ " not referring to the list argument");
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),
- "list::splice(iterator, list, iterator) called with second iterator not"
- " dereferenceable");
+ "list::splice(iterator, list, iterator) called with the second iterator"
+ " not dereferenceable");
#endif
if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
{
@@ -2098,7 +2097,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
" referring to this list");
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == &__c,
"list::splice(iterator, list, iterator, iterator) called with second iterator not"
- " referring to list argument");
+ " referring to the list argument");
+ _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == &__c,
+ "list::splice(iterator, list, iterator, iterator) called with third iterator not"
+ " referring to the list argument");
if (this == &__c)
{
for (const_iterator __i = __f; __i != __l; ++__i)
@@ -2412,7 +2414,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
return false;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
@@ -2489,4 +2491,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_LIST
+#endif // _LIBCPP_LIST
diff --git a/contrib/llvm-project/libcxx/include/locale b/contrib/llvm-project/libcxx/include/locale
index 9a705c77cfab..8e584005da08 100644
--- a/contrib/llvm-project/libcxx/include/locale
+++ b/contrib/llvm-project/libcxx/include/locale
@@ -188,23 +188,28 @@ template <class charT> class messages_byname;
*/
#include <__config>
-#include <__locale>
#include <__debug>
+#include <__locale>
#include <algorithm>
-#include <memory>
-#include <ios>
-#include <streambuf>
-#include <iterator>
-#include <limits>
-#include <version>
#ifndef __APPLE__
-#include <cstdarg>
+# include <cstdarg>
#endif
+#include <cstdio>
#include <cstdlib>
#include <ctime>
-#include <cstdio>
-#ifdef _LIBCPP_HAS_CATOPEN
-#include <nl_types.h>
+#include <ios>
+#include <iterator>
+#include <limits>
+#include <memory>
+#include <streambuf>
+#include <version>
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+// Most unix variants have catopen. These are the specific ones that don't.
+# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+# define _LIBCPP_HAS_CATOPEN 1
+# include <nl_types.h>
+# endif
#endif
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
@@ -1453,10 +1458,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
char __fmt[6] = {'%', 0};
const char* __len = "l";
this->__format_int(__fmt+1, __len, true, __iob.flags());
- const unsigned __nbuf = (numeric_limits<long>::digits / 3)
- + ((numeric_limits<long>::digits % 3) != 0)
- + ((__iob.flags() & ios_base::showbase) != 0)
- + 2;
+ // Worst case is octal, with showbase enabled. Note that octal is always
+ // printed as an unsigned value.
+ _LIBCPP_CONSTEXPR const unsigned __nbuf
+ = (numeric_limits<unsigned long>::digits / 3) // 1 char per 3 bits
+ + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up
+ + 2; // base prefix + terminating null character
char __nar[__nbuf];
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
char* __ne = __nar + __nc;
@@ -1480,10 +1487,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
char __fmt[8] = {'%', 0};
const char* __len = "ll";
this->__format_int(__fmt+1, __len, true, __iob.flags());
- const unsigned __nbuf = (numeric_limits<long long>::digits / 3)
- + ((numeric_limits<long long>::digits % 3) != 0)
- + ((__iob.flags() & ios_base::showbase) != 0)
- + 2;
+ // Worst case is octal, with showbase enabled. Note that octal is always
+ // printed as an unsigned value.
+ _LIBCPP_CONSTEXPR const unsigned __nbuf
+ = (numeric_limits<unsigned long long>::digits / 3) // 1 char per 3 bits
+ + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up
+ + 2; // base prefix + terminating null character
char __nar[__nbuf];
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
char* __ne = __nar + __nc;
@@ -1507,10 +1516,11 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
char __fmt[6] = {'%', 0};
const char* __len = "l";
this->__format_int(__fmt+1, __len, false, __iob.flags());
- const unsigned __nbuf = (numeric_limits<unsigned long>::digits / 3)
- + ((numeric_limits<unsigned long>::digits % 3) != 0)
- + ((__iob.flags() & ios_base::showbase) != 0)
- + 1;
+ // Worst case is octal, with showbase enabled.
+ _LIBCPP_CONSTEXPR const unsigned __nbuf
+ = (numeric_limits<unsigned long>::digits / 3) // 1 char per 3 bits
+ + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up
+ + 2; // base prefix + terminating null character
char __nar[__nbuf];
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
char* __ne = __nar + __nc;
@@ -1534,10 +1544,11 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
char __fmt[8] = {'%', 0};
const char* __len = "ll";
this->__format_int(__fmt+1, __len, false, __iob.flags());
- const unsigned __nbuf = (numeric_limits<unsigned long long>::digits / 3)
- + ((numeric_limits<unsigned long long>::digits % 3) != 0)
- + ((__iob.flags() & ios_base::showbase) != 0)
- + 1;
+ // Worst case is octal, with showbase enabled.
+ _LIBCPP_CONSTEXPR const unsigned __nbuf
+ = (numeric_limits<unsigned long long>::digits / 3) // 1 char per 3 bits
+ + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up
+ + 2; // base prefix + terminating null character
char __nar[__nbuf];
int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
char* __ne = __nar + __nc;
@@ -3567,7 +3578,7 @@ messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
__cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
return __cat;
#else // !_LIBCPP_HAS_CATOPEN
- _LIBCPP_UNUSED_VAR(__nm);
+ (void)__nm;
return -1;
#endif // _LIBCPP_HAS_CATOPEN
}
@@ -3591,9 +3602,9 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
__n, __n + _VSTD::strlen(__n));
return __w;
#else // !_LIBCPP_HAS_CATOPEN
- _LIBCPP_UNUSED_VAR(__c);
- _LIBCPP_UNUSED_VAR(__set);
- _LIBCPP_UNUSED_VAR(__msgid);
+ (void)__c;
+ (void)__set;
+ (void)__msgid;
return __dflt;
#endif // _LIBCPP_HAS_CATOPEN
}
@@ -3608,7 +3619,7 @@ messages<_CharT>::do_close(catalog __c) const
nl_catd __cat = (nl_catd)__c;
catclose(__cat);
#else // !_LIBCPP_HAS_CATOPEN
- _LIBCPP_UNUSED_VAR(__c);
+ (void)__c;
#endif // _LIBCPP_HAS_CATOPEN
}
@@ -3748,7 +3759,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
__wc.__cvtptr_ = nullptr;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert()
@@ -4376,4 +4387,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_LOCALE
+#endif // _LIBCPP_LOCALE
diff --git a/contrib/llvm-project/libcxx/include/locale.h b/contrib/llvm-project/libcxx/include/locale.h
index 81cfcee57fd7..65b2bd5fd724 100644
--- a/contrib/llvm-project/libcxx/include/locale.h
+++ b/contrib/llvm-project/libcxx/include/locale.h
@@ -45,4 +45,4 @@ Functions:
#include_next <locale.h>
-#endif // _LIBCPP_LOCALE_H
+#endif // _LIBCPP_LOCALE_H
diff --git a/contrib/llvm-project/libcxx/include/map b/contrib/llvm-project/libcxx/include/map
index a27002c279ec..513a04dd7923 100644
--- a/contrib/llvm-project/libcxx/include/map
+++ b/contrib/llvm-project/libcxx/include/map
@@ -43,7 +43,6 @@ public:
typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
class value_compare
- : public binary_function<value_type, value_type, bool>
{
friend class map;
protected:
@@ -51,6 +50,9 @@ public:
value_compare(key_compare c);
public:
+ typedef bool result_type; // deprecated in C++17, removed in C++20
+ typedef value_type first_argument_type; // deprecated in C++17, removed in C++20
+ typedef value_type second_argument_type; // deprecated in C++17, removed in C++20
bool operator()(const value_type& x, const value_type& y) const;
};
@@ -191,10 +193,14 @@ public:
iterator find(const K& x); // C++14
template<typename K>
const_iterator find(const K& x) const; // C++14
+
template<typename K>
size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
- bool contains(const key_type& x) const; // C++20
+
+ bool contains(const key_type& x) const; // C++20
+ template<class K> bool contains(const K& x) const; // C++20
+
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -283,13 +289,15 @@ public:
typedef unspecified node_type; // C++17
class value_compare
- : public binary_function<value_type,value_type,bool>
{
friend class multimap;
protected:
key_compare comp;
value_compare(key_compare c);
public:
+ typedef bool result_type; // deprecated in C++17, removed in C++20
+ typedef value_type first_argument_type; // deprecated in C++17, removed in C++20
+ typedef value_type second_argument_type; // deprecated in C++17, removed in C++20
bool operator()(const value_type& x, const value_type& y) const;
};
@@ -406,10 +414,14 @@ public:
iterator find(const K& x); // C++14
template<typename K>
const_iterator find(const K& x) const; // C++14
+
template<typename K>
size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
- bool contains(const key_type& x) const; // C++20
+
+ bool contains(const key_type& x) const; // C++20
+ template<class K> bool contains(const K& x) const; // C++20
+
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -478,14 +490,18 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
*/
#include <__config>
-#include <__tree>
+#include <__debug>
+#include <__functional/is_transparent.h>
#include <__node_handle>
-#include <iterator>
-#include <memory>
-#include <utility>
+#include <__tree>
+#include <__utility/forward.h>
+#include <compare>
#include <functional>
#include <initializer_list>
+#include <iterator> // __libcpp_erase_if_container
+#include <memory>
#include <type_traits>
+#include <utility>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -633,7 +649,7 @@ public:
{
__x.__value_constructed = false;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) _NOEXCEPT
@@ -656,7 +672,7 @@ template <class _TreeIterator> class __map_const_iterator;
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp>
-struct __value_type
+struct _LIBCPP_STANDALONE_DEBUG __value_type
{
typedef _Key key_type;
typedef _Tp mapped_type;
@@ -904,23 +920,32 @@ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type> value_type;
- typedef typename __identity<_Compare>::type key_compare;
- typedef typename __identity<_Allocator>::type allocator_type;
+ typedef __identity_t<_Compare> key_compare;
+ typedef __identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
class _LIBCPP_TEMPLATE_VIS value_compare
+#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
: public binary_function<value_type, value_type, bool>
+#endif
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
friend class map;
protected:
key_compare comp;
_LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}
public:
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
+#endif
_LIBCPP_INLINE_VISIBILITY
bool operator()(const value_type& __x, const value_type& __y) const
{return comp(__x.first, __y.first);}
@@ -1071,7 +1096,7 @@ public:
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit map(const allocator_type& __a)
@@ -1168,7 +1193,7 @@ public:
iterator insert(const_iterator __pos, _Pp&& __p)
{return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool>
@@ -1404,6 +1429,10 @@ public:
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
@@ -1565,7 +1594,7 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
return __r->__value_.__get_value().second;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp&
@@ -1660,7 +1689,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator,
inline _LIBCPP_INLINE_VISIBILITY
typename map<_Key, _Tp, _Compare, _Allocator>::size_type
erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -1674,17 +1703,21 @@ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type> value_type;
- typedef typename __identity<_Compare>::type key_compare;
- typedef typename __identity<_Allocator>::type allocator_type;
+ typedef __identity_t<_Compare> key_compare;
+ typedef __identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
class _LIBCPP_TEMPLATE_VIS value_compare
+#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
: public binary_function<value_type, value_type, bool>
+#endif
{
+_LIBCPP_SUPPRESS_DEPRECATED_POP
friend class multimap;
protected:
key_compare comp;
@@ -1692,6 +1725,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
value_compare(key_compare c) : comp(c) {}
public:
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type;
+#endif
_LIBCPP_INLINE_VISIBILITY
bool operator()(const value_type& __x, const value_type& __y) const
{return comp(__x.first, __y.first);}
@@ -1842,7 +1880,7 @@ public:
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit multimap(const allocator_type& __a)
@@ -1945,7 +1983,7 @@ public:
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);}
@@ -2070,6 +2108,10 @@ public:
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
@@ -2246,10 +2288,10 @@ inline _LIBCPP_INLINE_VISIBILITY
typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c,
_Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_MAP
+#endif // _LIBCPP_MAP
diff --git a/contrib/llvm-project/libcxx/include/math.h b/contrib/llvm-project/libcxx/include/math.h
index 1603d5748e2d..77762d554512 100644
--- a/contrib/llvm-project/libcxx/include/math.h
+++ b/contrib/llvm-project/libcxx/include/math.h
@@ -318,7 +318,11 @@ _LIBCPP_INLINE_VISIBILITY
bool
__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
{
+#if __has_builtin(__builtin_signbit)
+ return __builtin_signbit(__lcpp_x);
+#else
return signbit(__lcpp_x);
+#endif
}
#undef signbit
@@ -369,7 +373,7 @@ typename std::enable_if<
signbit(_A1) _NOEXCEPT
{ return false; }
-#endif // signbit
+#endif // signbit
// fpclassify
@@ -380,7 +384,12 @@ _LIBCPP_INLINE_VISIBILITY
int
__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
{
+#if __has_builtin(__builtin_fpclassify)
+ return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
+ FP_ZERO, __lcpp_x);
+#else
return fpclassify(__lcpp_x);
+#endif
}
#undef fpclassify
@@ -415,7 +424,7 @@ typename std::enable_if<std::is_integral<_A1>::value, int>::type
fpclassify(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
-#endif // fpclassify
+#endif // fpclassify
// isfinite
@@ -426,7 +435,11 @@ _LIBCPP_INLINE_VISIBILITY
bool
__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
{
+#if __has_builtin(__builtin_isfinite)
+ return __builtin_isfinite(__lcpp_x);
+#else
return isfinite(__lcpp_x);
+#endif
}
#undef isfinite
@@ -449,7 +462,7 @@ typename std::enable_if<
isfinite(_A1) _NOEXCEPT
{ return true; }
-#endif // isfinite
+#endif // isfinite
// isinf
@@ -460,7 +473,11 @@ _LIBCPP_INLINE_VISIBILITY
bool
__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
{
+#if __has_builtin(__builtin_isinf)
+ return __builtin_isinf(__lcpp_x);
+#else
return isinf(__lcpp_x);
+#endif
}
#undef isinf
@@ -497,7 +514,7 @@ bool
isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
#endif
-#endif // isinf
+#endif // isinf
// isnan
@@ -545,7 +562,7 @@ bool
isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
#endif
-#endif // isnan
+#endif // isnan
// isnormal
@@ -556,7 +573,11 @@ _LIBCPP_INLINE_VISIBILITY
bool
__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
{
+#if __has_builtin(__builtin_isnormal)
+ return __builtin_isnormal(__lcpp_x);
+#else
return isnormal(__lcpp_x);
+#endif
}
#undef isnormal
@@ -575,7 +596,7 @@ typename std::enable_if<std::is_integral<_A1>::value, bool>::type
isnormal(_A1 __lcpp_x) _NOEXCEPT
{ return __lcpp_x != 0; }
-#endif // isnormal
+#endif // isnormal
// isgreater
@@ -605,7 +626,7 @@ isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
}
-#endif // isgreater
+#endif // isgreater
// isgreaterequal
@@ -635,7 +656,7 @@ isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
}
-#endif // isgreaterequal
+#endif // isgreaterequal
// isless
@@ -665,7 +686,7 @@ isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
}
-#endif // isless
+#endif // isless
// islessequal
@@ -695,7 +716,7 @@ islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
}
-#endif // islessequal
+#endif // islessequal
// islessgreater
@@ -725,7 +746,7 @@ islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
}
-#endif // islessgreater
+#endif // islessgreater
// isunordered
@@ -755,7 +776,7 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
}
-#endif // isunordered
+#endif // isunordered
// abs
//
@@ -1099,16 +1120,43 @@ cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
// copysign
-inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
- float __lcpp_y) _NOEXCEPT {
+#if __has_builtin(__builtin_copysignf)
+_LIBCPP_CONSTEXPR
+#endif
+inline _LIBCPP_INLINE_VISIBILITY float __libcpp_copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
+#if __has_builtin(__builtin_copysignf)
+ return __builtin_copysignf(__lcpp_x, __lcpp_y);
+#else
return ::copysignf(__lcpp_x, __lcpp_y);
+#endif
+}
+
+#if __has_builtin(__builtin_copysign)
+_LIBCPP_CONSTEXPR
+#endif
+inline _LIBCPP_INLINE_VISIBILITY double __libcpp_copysign(double __lcpp_x, double __lcpp_y) _NOEXCEPT {
+#if __has_builtin(__builtin_copysign)
+ return __builtin_copysign(__lcpp_x, __lcpp_y);
+#else
+ return ::copysign(__lcpp_x, __lcpp_y);
+#endif
}
-inline _LIBCPP_INLINE_VISIBILITY long double
-copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
+
+#if __has_builtin(__builtin_copysignl)
+_LIBCPP_CONSTEXPR
+#endif
+inline _LIBCPP_INLINE_VISIBILITY long double __libcpp_copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
+#if __has_builtin(__builtin_copysignl)
+ return __builtin_copysignl(__lcpp_x, __lcpp_y);
+#else
return ::copysignl(__lcpp_x, __lcpp_y);
+#endif
}
template <class _A1, class _A2>
+#if __has_builtin(__builtin_copysign)
+_LIBCPP_CONSTEXPR
+#endif
inline _LIBCPP_INLINE_VISIBILITY
typename std::_EnableIf
<
@@ -1116,12 +1164,35 @@ typename std::_EnableIf
std::is_arithmetic<_A2>::value,
std::__promote<_A1, _A2>
>::type
-copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
-{
+__libcpp_copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
typedef typename std::__promote<_A1, _A2>::type __result_type;
static_assert((!(std::_IsSame<_A1, __result_type>::value &&
std::_IsSame<_A2, __result_type>::value)), "");
+#if __has_builtin(__builtin_copysign)
+ return __builtin_copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+#else
return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
+ return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
+ return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
+}
+
+template <class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::_EnableIf
+<
+ std::is_arithmetic<_A1>::value &&
+ std::is_arithmetic<_A2>::value,
+ std::__promote<_A1, _A2>
+>::type
+ copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
+ return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
}
// erf
@@ -1187,8 +1258,22 @@ fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// fma
-inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
-inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);}
+inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT
+{
+#if __has_builtin(__builtin_fmaf)
+ return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
+#else
+ return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT
+{
+#if __has_builtin(__builtin_fmal)
+ return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z);
+#else
+ return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);
+#endif
+}
template <class _A1, class _A2, class _A3>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1205,7 +1290,11 @@ fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
static_assert((!(std::_IsSame<_A1, __result_type>::value &&
std::_IsSame<_A2, __result_type>::value &&
std::_IsSame<_A3, __result_type>::value)), "");
+#if __has_builtin(__builtin_fma)
+ return __builtin_fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
+#else
return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
+#endif
}
// fmax
@@ -1293,23 +1382,65 @@ lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
// llrint
-inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return ::llrintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return ::llrintl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_llrintf)
+ return __builtin_llrintf(__lcpp_x);
+#else
+ return ::llrintf(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_llrintl)
+ return __builtin_llrintl(__lcpp_x);
+#else
+ return ::llrintl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, long long>::type
-llrint(_A1 __lcpp_x) _NOEXCEPT {return ::llrint((double)__lcpp_x);}
+llrint(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_llrint)
+ return __builtin_llrint((double)__lcpp_x);
+#else
+ return ::llrint((double)__lcpp_x);
+#endif
+}
// llround
-inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return ::llroundf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return ::llroundl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_llroundf)
+ return __builtin_llroundf(__lcpp_x);
+#else
+ return ::llroundf(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_llroundl)
+ return __builtin_llroundl(__lcpp_x);
+#else
+ return ::llroundl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, long long>::type
-llround(_A1 __lcpp_x) _NOEXCEPT {return ::llround((double)__lcpp_x);}
+llround(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_llround)
+ return __builtin_llround((double)__lcpp_x);
+#else
+ return ::llround((double)__lcpp_x);
+#endif
+}
// log1p
@@ -1343,23 +1474,65 @@ logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
// lrint
-inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return ::lrintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return ::lrintl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_lrintf)
+ return __builtin_lrintf(__lcpp_x);
+#else
+ return ::lrintf(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_lrintl)
+ return __builtin_lrintl(__lcpp_x);
+#else
+ return ::lrintl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, long>::type
-lrint(_A1 __lcpp_x) _NOEXCEPT {return ::lrint((double)__lcpp_x);}
+lrint(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_lrint)
+ return __builtin_lrint((double)__lcpp_x);
+#else
+ return ::lrint((double)__lcpp_x);
+#endif
+}
// lround
-inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return ::lroundf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return ::lroundl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_lroundf)
+ return __builtin_lroundf(__lcpp_x);
+#else
+ return ::lroundf(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_lroundl)
+ return __builtin_lroundl(__lcpp_x);
+#else
+ return ::lroundl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, long>::type
-lround(_A1 __lcpp_x) _NOEXCEPT {return ::lround((double)__lcpp_x);}
+lround(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_lround)
+ return __builtin_lround((double)__lcpp_x);
+#else
+ return ::lround((double)__lcpp_x);
+#endif
+}
// nan
@@ -1448,23 +1621,65 @@ remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
// rint
-inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return ::rintf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return ::rintl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_rintf)
+ return __builtin_rintf(__lcpp_x);
+#else
+ return ::rintf(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_rintl)
+ return __builtin_rintl(__lcpp_x);
+#else
+ return ::rintl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-rint(_A1 __lcpp_x) _NOEXCEPT {return ::rint((double)__lcpp_x);}
+rint(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_rint)
+ return __builtin_rint((double)__lcpp_x);
+#else
+ return ::rint((double)__lcpp_x);
+#endif
+}
// round
-inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return ::roundf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return ::roundl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_round)
+ return __builtin_round(__lcpp_x);
+#else
+ return ::round(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_roundl)
+ return __builtin_roundl(__lcpp_x);
+#else
+ return ::roundl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-round(_A1 __lcpp_x) _NOEXCEPT {return ::round((double)__lcpp_x);}
+round(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_round)
+ return __builtin_round((double)__lcpp_x);
+#else
+ return ::round((double)__lcpp_x);
+#endif
+}
// scalbln
@@ -1498,13 +1713,34 @@ tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
// trunc
-inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return ::truncf(__lcpp_x);}
-inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return ::truncl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_trunc)
+ return __builtin_trunc(__lcpp_x);
+#else
+ return ::trunc(__lcpp_x);
+#endif
+}
+inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_truncl)
+ return __builtin_truncl(__lcpp_x);
+#else
+ return ::truncl(__lcpp_x);
+#endif
+}
template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, double>::type
-trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
+trunc(_A1 __lcpp_x) _NOEXCEPT
+{
+#if __has_builtin(__builtin_trunc)
+ return __builtin_trunc((double)__lcpp_x);
+#else
+ return ::trunc((double)__lcpp_x);
+#endif
+}
} // extern "C++"
@@ -1524,4 +1760,4 @@ trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
#include_next <math.h>
#endif
-#endif // _LIBCPP_MATH_H
+#endif // _LIBCPP_MATH_H
diff --git a/contrib/llvm-project/libcxx/include/memory b/contrib/llvm-project/libcxx/include/memory
index 62235cf72b35..fdb894353008 100644
--- a/contrib/llvm-project/libcxx/include/memory
+++ b/contrib/llvm-project/libcxx/include/memory
@@ -102,11 +102,11 @@ template <>
class allocator<void> // removed in C++20
{
public:
- typedef void* pointer; // deprecated in C++17
- typedef const void* const_pointer; // deprecated in C++17
- typedef void value_type; // deprecated in C++17
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ typedef void value_type;
- template <class _Up> struct rebind {typedef allocator<_Up> other;}; // deprecated in C++17
+ template <class _Up> struct rebind {typedef allocator<_Up> other;};
};
template <class T>
@@ -153,14 +153,17 @@ template <class T, class U>
bool operator!=(const allocator<T>&, const allocator<U>&) noexcept; // constexpr in C++20
template <class OutputIterator, class T>
-class raw_storage_iterator
- : public iterator<output_iterator_tag,
- T, // purposefully not C++03
- ptrdiff_t, // purposefully not C++03
- T*, // purposefully not C++03
- raw_storage_iterator&> // purposefully not C++03
+class raw_storage_iterator // deprecated in C++17, removed in C++20
+ : public iterator<output_iterator_tag, void, void, void, void> // until C++17
{
public:
+ typedef output_iterator_tag iterator_category;
+ typedef void value_type;
+ typedef void difference_type; // until C++20
+ typedef ptrdiff_t difference_type; // since C++20
+ typedef void pointer;
+ typedef void reference;
+
explicit raw_storage_iterator(OutputIterator x);
raw_storage_iterator& operator*();
raw_storage_iterator& operator=(const T& element);
@@ -651,12 +654,12 @@ template <class T, class Alloc>
inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
// Pointer safety
-enum class pointer_safety { relaxed, preferred, strict };
-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;
+enum class pointer_safety { relaxed, preferred, strict }; // since C++11
+void declare_reachable(void *p); // since C++11
+template <class T> T *undeclare_reachable(T *p); // since C++11
+void declare_no_pointers(char *p, size_t n); // since C++11
+void undeclare_no_pointers(char *p, size_t n); // since C++11
+pointer_safety get_pointer_safety() noexcept; // since C++11
void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
@@ -665,29 +668,40 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
*/
#include <__config>
-#include <__availability>
-#include <type_traits>
-#include <typeinfo>
+#include <__functional_base>
+#include <__memory/addressof.h>
+#include <__memory/allocation_guard.h>
+#include <__memory/allocator.h>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/allocator_traits.h>
+#include <__memory/compressed_pair.h>
+#include <__memory/construct_at.h>
+#include <__memory/pointer_safety.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/raw_storage_iterator.h>
+#include <__memory/shared_ptr.h>
+#include <__memory/temporary_buffer.h>
+#include <__memory/uninitialized_algorithms.h>
+#include <__memory/unique_ptr.h>
+#include <__memory/uses_allocator.h>
+#include <compare>
#include <cstddef>
#include <cstdint>
-#include <new>
-#include <utility>
-#include <limits>
-#include <iterator>
-#include <__functional_base>
+#include <cstring>
#include <iosfwd>
-#include <tuple>
+#include <iterator>
+#include <new>
#include <stdexcept>
-#include <cstring>
-#include <__memory/allocator_traits.h>
-#include <__memory/base.h>
-#include <__memory/pointer_traits.h>
-#include <__memory/utilities.h>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-# include <atomic>
-#endif
+#include <tuple>
+#include <type_traits>
+#include <typeinfo>
+#include <utility>
#include <version>
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
+# include <__memory/auto_ptr.h>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -698,312 +712,6 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
-#if !defined(_LIBCPP_HAS_NO_THREADS) && \
- defined(__ATOMIC_RELAXED) && \
- (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
- return __atomic_load_n(__value, __ATOMIC_RELAXED);
-#else
- return *__value;
-#endif
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_acquire_load(_ValueType const* __value) {
-#if !defined(_LIBCPP_HAS_NO_THREADS) && \
- defined(__ATOMIC_ACQUIRE) && \
- (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
- return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
-#else
- return *__value;
-#endif
-}
-
-template <bool _UsePointerTraits> struct __to_address_helper;
-
-template <> struct __to_address_helper<true> {
- template <class _Pointer>
- using __return_type = decltype(pointer_traits<_Pointer>::to_address(_VSTD::declval<const _Pointer&>()));
-
- template <class _Pointer>
- _LIBCPP_CONSTEXPR
- static __return_type<_Pointer>
- __do_it(const _Pointer &__p) _NOEXCEPT { return pointer_traits<_Pointer>::to_address(__p); }
-};
-
-template <class _Pointer, bool _Dummy = true>
-using __choose_to_address = __to_address_helper<_IsValidExpansion<__to_address_helper<_Dummy>::template __return_type, _Pointer>::value>;
-
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-_Tp*
-__to_address(_Tp* __p) _NOEXCEPT
-{
- static_assert(!is_function<_Tp>::value, "_Tp is a function type");
- return __p;
-}
-
-template <class _Pointer>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename __choose_to_address<_Pointer>::template __return_type<_Pointer>
-__to_address(const _Pointer& __p) _NOEXCEPT {
- return __choose_to_address<_Pointer>::__do_it(__p);
-}
-
-template <> struct __to_address_helper<false> {
- template <class _Pointer>
- using __return_type = typename pointer_traits<_Pointer>::element_type*;
-
- template <class _Pointer>
- _LIBCPP_CONSTEXPR
- static __return_type<_Pointer>
- __do_it(const _Pointer &__p) _NOEXCEPT { return _VSTD::__to_address(__p.operator->()); }
-};
-
-
-#if _LIBCPP_STD_VER > 17
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY constexpr
-_Tp*
-to_address(_Tp* __p) _NOEXCEPT
-{
- static_assert(!is_function_v<_Tp>, "_Tp is a function type");
- return __p;
-}
-
-template <class _Pointer>
-inline _LIBCPP_INLINE_VISIBILITY constexpr
-auto
-to_address(const _Pointer& __p) _NOEXCEPT
-{
- return _VSTD::__to_address(__p);
-}
-#endif
-
-template <class _Tp> class allocator;
-
-#if _LIBCPP_STD_VER <= 17
-template <>
-class _LIBCPP_TEMPLATE_VIS allocator<void>
-{
-public:
- _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type;
-
- template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
-};
-
-template <>
-class _LIBCPP_TEMPLATE_VIS allocator<const void>
-{
-public:
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;
-
- template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
-};
-#endif
-
-// This class provides a non-trivial default constructor to the class that derives from it
-// if the condition is satisfied.
-//
-// The second template parameter exists to allow giving a unique type to __non_trivial_if,
-// which makes it possible to avoid breaking the ABI when making this a base class of an
-// existing class. Without that, imagine we have classes D1 and D2, both of which used to
-// have no base classes, but which now derive from __non_trivial_if. The layout of a class
-// that inherits from both D1 and D2 will change because the two __non_trivial_if base
-// classes are not allowed to share the same address.
-//
-// By making those __non_trivial_if base classes unique, we work around this problem and
-// it is safe to start deriving from __non_trivial_if in existing classes.
-template <bool _Cond, class _Unique>
-struct __non_trivial_if { };
-
-template <class _Unique>
-struct __non_trivial_if<true, _Unique> {
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __non_trivial_if() _NOEXCEPT { }
-};
-
-// allocator
-//
-// Note: For ABI compatibility between C++20 and previous standards, we make
-// allocator<void> trivial in C++20.
-
-template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS allocator
- : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> >
-{
-public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _Tp value_type;
- typedef true_type propagate_on_container_move_assignment;
- typedef true_type is_always_equal;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator() _NOEXCEPT _LIBCPP_DEFAULT
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator(const allocator<_Up>&) _NOEXCEPT { }
-
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- _Tp* allocate(size_t __n) {
- if (__n > allocator_traits<allocator>::max_size(*this))
- __throw_length_error("allocator<T>::allocate(size_t n)"
- " 'n' exceeds maximum supported size");
- if (__libcpp_is_constant_evaluated()) {
- return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
- } else {
- return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
- if (__libcpp_is_constant_evaluated()) {
- ::operator delete(__p);
- } else {
- _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
- }
- }
-
- // C++20 Removed members
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
-
- template <class _Up>
- struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
- typedef allocator<_Up> other;
- };
-
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- pointer address(reference __x) const _NOEXCEPT {
- return _VSTD::addressof(__x);
- }
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- const_pointer address(const_reference __x) const _NOEXCEPT {
- return _VSTD::addressof(__x);
- }
-
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
- _Tp* allocate(size_t __n, const void*) {
- return allocate(__n);
- }
-
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
- return size_type(~0) / sizeof(_Tp);
- }
-
- template <class _Up, class... _Args>
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void construct(_Up* __p, _Args&&... __args) {
- ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
- }
-
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void destroy(pointer __p) {
- __p->~_Tp();
- }
-#endif
-};
-
-template <class _Tp>
-class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
- : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> >
-{
-public:
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef const _Tp value_type;
- typedef true_type propagate_on_container_move_assignment;
- typedef true_type is_always_equal;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator() _NOEXCEPT _LIBCPP_DEFAULT
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- allocator(const allocator<_Up>&) _NOEXCEPT { }
-
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- const _Tp* allocate(size_t __n) {
- if (__n > allocator_traits<allocator>::max_size(*this))
- __throw_length_error("allocator<const T>::allocate(size_t n)"
- " 'n' exceeds maximum supported size");
- if (__libcpp_is_constant_evaluated()) {
- return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
- } else {
- return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void deallocate(const _Tp* __p, size_t __n) {
- if (__libcpp_is_constant_evaluated()) {
- ::operator delete(const_cast<_Tp*>(__p));
- } else {
- _VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
- }
- }
-
- // C++20 Removed members
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
- _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
-
- template <class _Up>
- struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
- typedef allocator<_Up> other;
- };
-
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- const_pointer address(const_reference __x) const _NOEXCEPT {
- return _VSTD::addressof(__x);
- }
-
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
- const _Tp* allocate(size_t __n, const void*) {
- return allocate(__n);
- }
-
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
- return size_type(~0) / sizeof(_Tp);
- }
-
- template <class _Up, class... _Args>
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void construct(_Up* __p, _Args&&... __args) {
- ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
- }
-
- _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
- void destroy(pointer __p) {
- __p->~_Tp();
- }
-#endif
-};
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
-
template <class _Alloc, class _Ptr>
_LIBCPP_INLINE_VISIBILITY
void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) {
@@ -1088,1045 +796,9 @@ void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp*
ptrdiff_t _Np = __end1 - __begin1;
__end2 -= _Np;
if (_Np > 0)
- _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
-}
-
-template <class _OutputIterator, class _Tp>
-class _LIBCPP_TEMPLATE_VIS raw_storage_iterator
- : public iterator<output_iterator_tag,
- _Tp, // purposefully not C++03
- ptrdiff_t, // purposefully not C++03
- _Tp*, // purposefully not C++03
- raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03
-{
-private:
- _OutputIterator __x_;
-public:
- _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
- _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;}
- _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element)
- {::new ((void*)_VSTD::addressof(*__x_)) _Tp(__element); return *this;}
-#if _LIBCPP_STD_VER >= 14
- _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element)
- {::new ((void*)_VSTD::addressof(*__x_)) _Tp(_VSTD::move(__element)); return *this;}
-#endif
- _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
- _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
- {raw_storage_iterator __t(*this); ++__x_; return __t;}
-#if _LIBCPP_STD_VER >= 14
- _LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; }
-#endif
-};
-
-template <class _Tp>
-_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI
-pair<_Tp*, ptrdiff_t>
-get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
-{
- pair<_Tp*, ptrdiff_t> __r(0, 0);
- const ptrdiff_t __m = (~ptrdiff_t(0) ^
- ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1)))
- / sizeof(_Tp);
- if (__n > __m)
- __n = __m;
- while (__n > 0)
- {
-#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
- if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))
- {
- align_val_t __al =
- align_val_t(alignment_of<_Tp>::value);
- __r.first = static_cast<_Tp*>(::operator new(
- __n * sizeof(_Tp), __al, nothrow));
- } else {
- __r.first = static_cast<_Tp*>(::operator new(
- __n * sizeof(_Tp), nothrow));
- }
-#else
- if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp)))
- {
- // Since aligned operator new is unavailable, return an empty
- // buffer rather than one with invalid alignment.
- return __r;
- }
-
- __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
-#endif
-
- if (__r.first)
- {
- __r.second = __n;
- break;
- }
- __n /= 2;
- }
- return __r;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void return_temporary_buffer(_Tp* __p) _NOEXCEPT
-{
- _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp));
+ _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp));
}
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-template <class _Tp>
-struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref
-{
- _Tp* __ptr_;
-};
-
-template<class _Tp>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr
-{
-private:
- _Tp* __ptr_;
-public:
- typedef _Tp element_type;
-
- _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) _NOEXCEPT : __ptr_(__p) {}
- _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) _NOEXCEPT : __ptr_(__p.release()) {}
- template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) _NOEXCEPT
- : __ptr_(__p.release()) {}
- _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) _NOEXCEPT
- {reset(__p.release()); return *this;}
- template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) _NOEXCEPT
- {reset(__p.release()); return *this;}
- _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) _NOEXCEPT
- {reset(__p.__ptr_); return *this;}
- _LIBCPP_INLINE_VISIBILITY ~auto_ptr() _NOEXCEPT {delete __ptr_;}
-
- _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const _NOEXCEPT
- {return *__ptr_;}
- _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const _NOEXCEPT {return __ptr_;}
- _LIBCPP_INLINE_VISIBILITY _Tp* get() const _NOEXCEPT {return __ptr_;}
- _LIBCPP_INLINE_VISIBILITY _Tp* release() _NOEXCEPT
- {
- _Tp* __t = __ptr_;
- __ptr_ = nullptr;
- return __t;
- }
- _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) _NOEXCEPT
- {
- if (__ptr_ != __p)
- delete __ptr_;
- __ptr_ = __p;
- }
-
- _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
- template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() _NOEXCEPT
- {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;}
- template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() _NOEXCEPT
- {return auto_ptr<_Up>(release());}
-};
-
-template <>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void>
-{
-public:
- typedef void element_type;
-};
-#endif
-
-// Tag used to default initialize one or both of the pair's elements.
-struct __default_init_tag {};
-struct __value_init_tag {};
-
-template <class _Tp, int _Idx,
- bool _CanBeEmptyBase =
- is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
-struct __compressed_pair_elem {
- typedef _Tp _ParamT;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __compressed_pair_elem(__default_init_tag) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __compressed_pair_elem(__value_init_tag) : __value_() {}
-
- template <class _Up, class = typename enable_if<
- !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
- >::type>
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR explicit
- __compressed_pair_elem(_Up&& __u)
- : __value_(_VSTD::forward<_Up>(__u))
- {
- }
-
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class... _Args, size_t... _Indexes>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
- __tuple_indices<_Indexes...>)
- : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
-#endif
-
-
- _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
- _LIBCPP_INLINE_VISIBILITY
- const_reference __get() const _NOEXCEPT { return __value_; }
-
-private:
- _Tp __value_;
-};
-
-template <class _Tp, int _Idx>
-struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
- typedef _Tp _ParamT;
- typedef _Tp& reference;
- typedef const _Tp& const_reference;
- typedef _Tp __value_type;
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __compressed_pair_elem(__default_init_tag) {}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __compressed_pair_elem(__value_init_tag) : __value_type() {}
-
- template <class _Up, class = typename enable_if<
- !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
- >::type>
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR explicit
- __compressed_pair_elem(_Up&& __u)
- : __value_type(_VSTD::forward<_Up>(__u))
- {}
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class... _Args, size_t... _Indexes>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args,
- __tuple_indices<_Indexes...>)
- : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
-#endif
-
- _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
- _LIBCPP_INLINE_VISIBILITY
- const_reference __get() const _NOEXCEPT { return *this; }
-};
-
-template <class _T1, class _T2>
-class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
- private __compressed_pair_elem<_T2, 1> {
-public:
- // NOTE: This static assert should never fire because __compressed_pair
- // is *almost never* used in a scenario where it's possible for T1 == T2.
- // (The exception is std::function where it is possible that the function
- // object and the allocator have the same type).
- static_assert((!is_same<_T1, _T2>::value),
- "__compressed_pair cannot be instantiated when T1 and T2 are the same type; "
- "The current implementation is NOT ABI-compatible with the previous "
- "implementation for this configuration");
-
- typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1;
- typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2;
-
- template <bool _Dummy = true,
- class = typename enable_if<
- __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
- __dependent_type<is_default_constructible<_T2>, _Dummy>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
-
- template <class _U1, class _U2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- __compressed_pair(_U1&& __t1, _U2&& __t2)
- : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {}
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class... _Args1, class... _Args2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
- tuple<_Args2...> __second_args)
- : _Base1(__pc, _VSTD::move(__first_args),
- typename __make_tuple_indices<sizeof...(_Args1)>::type()),
- _Base2(__pc, _VSTD::move(__second_args),
- typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
-#endif
-
- _LIBCPP_INLINE_VISIBILITY
- typename _Base1::reference first() _NOEXCEPT {
- return static_cast<_Base1&>(*this).__get();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- typename _Base1::const_reference first() const _NOEXCEPT {
- return static_cast<_Base1 const&>(*this).__get();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- typename _Base2::reference second() _NOEXCEPT {
- return static_cast<_Base2&>(*this).__get();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- typename _Base2::const_reference second() const _NOEXCEPT {
- return static_cast<_Base2 const&>(*this).__get();
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT {
- return static_cast<_Base1*>(__pair);
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT {
- return static_cast<_Base2*>(__pair);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(__compressed_pair& __x)
- _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
- __is_nothrow_swappable<_T2>::value)
- {
- using _VSTD::swap;
- swap(first(), __x.first());
- swap(second(), __x.second());
- }
-};
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
- _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
- __is_nothrow_swappable<_T2>::value) {
- __x.swap(__y);
-}
-
-// default_delete
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS default_delete {
- static_assert(!is_function<_Tp>::value,
- "default_delete cannot be instantiated for function types");
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY constexpr default_delete() _NOEXCEPT = default;
-#else
- _LIBCPP_INLINE_VISIBILITY default_delete() {}
-#endif
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- default_delete(const default_delete<_Up>&,
- typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* =
- 0) _NOEXCEPT {}
-
- _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {
- static_assert(sizeof(_Tp) > 0,
- "default_delete can not delete incomplete type");
- static_assert(!is_void<_Tp>::value,
- "default_delete can not delete incomplete type");
- delete __ptr;
- }
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> {
-private:
- template <class _Up>
- struct _EnableIfConvertible
- : enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value> {};
-
-public:
-#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY constexpr default_delete() _NOEXCEPT = default;
-#else
- _LIBCPP_INLINE_VISIBILITY default_delete() {}
-#endif
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- default_delete(const default_delete<_Up[]>&,
- typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
-
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- typename _EnableIfConvertible<_Up>::type
- operator()(_Up* __ptr) const _NOEXCEPT {
- static_assert(sizeof(_Tp) > 0,
- "default_delete can not delete incomplete type");
- static_assert(!is_void<_Tp>::value,
- "default_delete can not delete void type");
- delete[] __ptr;
- }
-};
-
-template <class _Deleter>
-struct __unique_ptr_deleter_sfinae {
- static_assert(!is_reference<_Deleter>::value, "incorrect specialization");
- typedef const _Deleter& __lval_ref_type;
- typedef _Deleter&& __good_rval_ref_type;
- typedef true_type __enable_rval_overload;
-};
-
-template <class _Deleter>
-struct __unique_ptr_deleter_sfinae<_Deleter const&> {
- typedef const _Deleter& __lval_ref_type;
- typedef const _Deleter&& __bad_rval_ref_type;
- typedef false_type __enable_rval_overload;
-};
-
-template <class _Deleter>
-struct __unique_ptr_deleter_sfinae<_Deleter&> {
- typedef _Deleter& __lval_ref_type;
- typedef _Deleter&& __bad_rval_ref_type;
- typedef false_type __enable_rval_overload;
-};
-
-#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)
-# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
-#else
-# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI
-#endif
-
-template <class _Tp, class _Dp = default_delete<_Tp> >
-class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
-public:
- typedef _Tp element_type;
- typedef _Dp deleter_type;
- typedef _LIBCPP_NODEBUG_TYPE typename __pointer<_Tp, deleter_type>::type pointer;
-
- static_assert(!is_rvalue_reference<deleter_type>::value,
- "the specified deleter type cannot be an rvalue reference");
-
-private:
- __compressed_pair<pointer, deleter_type> __ptr_;
-
- struct __nat { int __for_bool_; };
-
- typedef _LIBCPP_NODEBUG_TYPE __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
-
- template <bool _Dummy>
- using _LValRefType _LIBCPP_NODEBUG_TYPE =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
-
- template <bool _Dummy>
- using _GoodRValRefType _LIBCPP_NODEBUG_TYPE =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
-
- template <bool _Dummy>
- using _BadRValRefType _LIBCPP_NODEBUG_TYPE =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
-
- template <bool _Dummy, class _Deleter = typename __dependent_type<
- __identity<deleter_type>, _Dummy>::type>
- using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE =
- typename enable_if<is_default_constructible<_Deleter>::value &&
- !is_pointer<_Deleter>::value>::type;
-
- template <class _ArgType>
- using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE =
- typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
-
- template <class _UPtr, class _Up>
- using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
- is_convertible<typename _UPtr::pointer, pointer>::value &&
- !is_array<_Up>::value
- >::type;
-
- template <class _UDel>
- using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
- (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
- (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
- >::type;
-
- template <class _UDel>
- using _EnableIfDeleterAssignable = typename enable_if<
- is_assignable<_Dp&, _UDel&&>::value
- >::type;
-
-public:
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __default_init_tag()) {}
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
- : __ptr_(__p, __d) {}
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
- : __ptr_(__p, _VSTD::move(__d)) {
- static_assert(!is_reference<deleter_type>::value,
- "rvalue deleter bound to reference");
- }
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr&& __u) _NOEXCEPT
- : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
- }
-
- template <class _Up, class _Ep,
- class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
- class = _EnableIfDeleterConvertible<_Ep>
- >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
- : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(auto_ptr<_Up>&& __p,
- typename enable_if<is_convertible<_Up*, _Tp*>::value &&
- is_same<_Dp, default_delete<_Tp> >::value,
- __nat>::type = __nat()) _NOEXCEPT
- : __ptr_(__p.release(), __default_init_tag()) {}
-#endif
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
- reset(__u.release());
- __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
- return *this;
- }
-
- template <class _Up, class _Ep,
- class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
- class = _EnableIfDeleterAssignable<_Ep>
- >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
- reset(__u.release());
- __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
- return *this;
- }
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if<is_convertible<_Up*, _Tp*>::value &&
- is_same<_Dp, default_delete<_Tp> >::value,
- unique_ptr&>::type
- operator=(auto_ptr<_Up> __p) {
- reset(__p.release());
- return *this;
- }
-#endif
-
-#ifdef _LIBCPP_CXX03_LANG
- unique_ptr(unique_ptr const&) = delete;
- unique_ptr& operator=(unique_ptr const&) = delete;
-#endif
-
-
- _LIBCPP_INLINE_VISIBILITY
- ~unique_ptr() { reset(); }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(nullptr_t) _NOEXCEPT {
- reset();
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- typename add_lvalue_reference<_Tp>::type
- operator*() const {
- return *__ptr_.first();
- }
- _LIBCPP_INLINE_VISIBILITY
- pointer operator->() const _NOEXCEPT {
- return __ptr_.first();
- }
- _LIBCPP_INLINE_VISIBILITY
- pointer get() const _NOEXCEPT {
- return __ptr_.first();
- }
- _LIBCPP_INLINE_VISIBILITY
- deleter_type& get_deleter() _NOEXCEPT {
- return __ptr_.second();
- }
- _LIBCPP_INLINE_VISIBILITY
- const deleter_type& get_deleter() const _NOEXCEPT {
- return __ptr_.second();
- }
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {
- return __ptr_.first() != nullptr;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- pointer release() _NOEXCEPT {
- pointer __t = __ptr_.first();
- __ptr_.first() = pointer();
- return __t;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void reset(pointer __p = pointer()) _NOEXCEPT {
- pointer __tmp = __ptr_.first();
- __ptr_.first() = __p;
- if (__tmp)
- __ptr_.second()(__tmp);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(unique_ptr& __u) _NOEXCEPT {
- __ptr_.swap(__u.__ptr_);
- }
-};
-
-
-template <class _Tp, class _Dp>
-class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {
-public:
- typedef _Tp element_type;
- typedef _Dp deleter_type;
- typedef typename __pointer<_Tp, deleter_type>::type pointer;
-
-private:
- __compressed_pair<pointer, deleter_type> __ptr_;
-
- template <class _From>
- struct _CheckArrayPointerConversion : is_same<_From, pointer> {};
-
- template <class _FromElem>
- struct _CheckArrayPointerConversion<_FromElem*>
- : integral_constant<bool,
- is_same<_FromElem*, pointer>::value ||
- (is_same<pointer, element_type*>::value &&
- is_convertible<_FromElem(*)[], element_type(*)[]>::value)
- >
- {};
-
- typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
-
- template <bool _Dummy>
- using _LValRefType _LIBCPP_NODEBUG_TYPE =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
-
- template <bool _Dummy>
- using _GoodRValRefType _LIBCPP_NODEBUG_TYPE =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
-
- template <bool _Dummy>
- using _BadRValRefType _LIBCPP_NODEBUG_TYPE =
- typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
-
- template <bool _Dummy, class _Deleter = typename __dependent_type<
- __identity<deleter_type>, _Dummy>::type>
- using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE =
- typename enable_if<is_default_constructible<_Deleter>::value &&
- !is_pointer<_Deleter>::value>::type;
-
- template <class _ArgType>
- using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE =
- typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
-
- template <class _Pp>
- using _EnableIfPointerConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
- _CheckArrayPointerConversion<_Pp>::value
- >::type;
-
- template <class _UPtr, class _Up,
- class _ElemT = typename _UPtr::element_type>
- using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
- is_array<_Up>::value &&
- is_same<pointer, element_type*>::value &&
- is_same<typename _UPtr::pointer, _ElemT*>::value &&
- is_convertible<_ElemT(*)[], element_type(*)[]>::value
- >::type;
-
- template <class _UDel>
- using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
- (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
- (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
- >::type;
-
- template <class _UDel>
- using _EnableIfDeleterAssignable _LIBCPP_NODEBUG_TYPE = typename enable_if<
- is_assignable<_Dp&, _UDel&&>::value
- >::type;
-
-public:
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy> >
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {}
-
- template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy>,
- class = _EnableIfPointerConvertible<_Pp> >
- _LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(_Pp __p) _NOEXCEPT
- : __ptr_(__p, __default_init_tag()) {}
-
- template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
- class = _EnableIfPointerConvertible<_Pp> >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT
- : __ptr_(__p, __d) {}
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
- : __ptr_(nullptr, __d) {}
-
- template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
- class = _EnableIfPointerConvertible<_Pp> >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
- : __ptr_(__p, _VSTD::move(__d)) {
- static_assert(!is_reference<deleter_type>::value,
- "rvalue deleter bound to reference");
- }
-
- template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
- : __ptr_(nullptr, _VSTD::move(__d)) {
- static_assert(!is_reference<deleter_type>::value,
- "rvalue deleter bound to reference");
- }
-
- template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
- class = _EnableIfPointerConvertible<_Pp> >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr&& __u) _NOEXCEPT
- : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
- }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
- reset(__u.release());
- __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
- return *this;
- }
-
- template <class _Up, class _Ep,
- class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
- class = _EnableIfDeleterConvertible<_Ep>
- >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
- : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {
- }
-
- template <class _Up, class _Ep,
- class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
- class = _EnableIfDeleterAssignable<_Ep>
- >
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr&
- operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
- reset(__u.release());
- __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
- return *this;
- }
-
-#ifdef _LIBCPP_CXX03_LANG
- unique_ptr(unique_ptr const&) = delete;
- unique_ptr& operator=(unique_ptr const&) = delete;
-#endif
-
-public:
- _LIBCPP_INLINE_VISIBILITY
- ~unique_ptr() { reset(); }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(nullptr_t) _NOEXCEPT {
- reset();
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- typename add_lvalue_reference<_Tp>::type
- operator[](size_t __i) const {
- return __ptr_.first()[__i];
- }
- _LIBCPP_INLINE_VISIBILITY
- pointer get() const _NOEXCEPT {
- return __ptr_.first();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- deleter_type& get_deleter() _NOEXCEPT {
- return __ptr_.second();
- }
-
- _LIBCPP_INLINE_VISIBILITY
- const deleter_type& get_deleter() const _NOEXCEPT {
- return __ptr_.second();
- }
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {
- return __ptr_.first() != nullptr;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- pointer release() _NOEXCEPT {
- pointer __t = __ptr_.first();
- __ptr_.first() = pointer();
- return __t;
- }
-
- template <class _Pp>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if<
- _CheckArrayPointerConversion<_Pp>::value
- >::type
- reset(_Pp __p) _NOEXCEPT {
- pointer __tmp = __ptr_.first();
- __ptr_.first() = __p;
- if (__tmp)
- __ptr_.second()(__tmp);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void reset(nullptr_t = nullptr) _NOEXCEPT {
- pointer __tmp = __ptr_.first();
- __ptr_.first() = nullptr;
- if (__tmp)
- __ptr_.second()(__tmp);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(unique_ptr& __u) _NOEXCEPT {
- __ptr_.swap(__u.__ptr_);
- }
-
-};
-
-template <class _Tp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<
- __is_swappable<_Dp>::value,
- void
->::type
-swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
-
-template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}
-
-template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
-
-template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator< (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y)
-{
- typedef typename unique_ptr<_T1, _D1>::pointer _P1;
- typedef typename unique_ptr<_T2, _D2>::pointer _P2;
- typedef typename common_type<_P1, _P2>::type _Vp;
- return less<_Vp>()(__x.get(), __y.get());
-}
-
-template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;}
-
-template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);}
-
-template <class _T1, class _D1, class _T2, class _D2>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
-{
- return !__x;
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
-{
- return !__x;
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
-{
- return static_cast<bool>(__x);
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
-{
- return static_cast<bool>(__x);
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t)
-{
- typedef typename unique_ptr<_T1, _D1>::pointer _P1;
- return less<_P1>()(__x.get(), nullptr);
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x)
-{
- typedef typename unique_ptr<_T1, _D1>::pointer _P1;
- return less<_P1>()(nullptr, __x.get());
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t)
-{
- return nullptr < __x;
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x)
-{
- return __x < nullptr;
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
-{
- return !(nullptr < __x);
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
-{
- return !(__x < nullptr);
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
-{
- return !(__x < nullptr);
-}
-
-template <class _T1, class _D1>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
-{
- return !(nullptr < __x);
-}
-
-#if _LIBCPP_STD_VER > 11
-
-template<class _Tp>
-struct __unique_if
-{
- typedef unique_ptr<_Tp> __unique_single;
-};
-
-template<class _Tp>
-struct __unique_if<_Tp[]>
-{
- typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
-};
-
-template<class _Tp, size_t _Np>
-struct __unique_if<_Tp[_Np]>
-{
- typedef void __unique_array_known_bound;
-};
-
-template<class _Tp, class... _Args>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __unique_if<_Tp>::__unique_single
-make_unique(_Args&&... __args)
-{
- return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename __unique_if<_Tp>::__unique_array_unknown_bound
-make_unique(size_t __n)
-{
- typedef typename remove_extent<_Tp>::type _Up;
- return unique_ptr<_Tp>(new _Up[__n]());
-}
-
-template<class _Tp, class... _Args>
- typename __unique_if<_Tp>::__unique_array_known_bound
- make_unique(_Args&&...) = delete;
-
-#endif // _LIBCPP_STD_VER > 11
-
-template <class _Tp, class _Dp>
-#ifdef _LIBCPP_CXX03_LANG
-struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
-#else
-struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper<
- unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
-#endif
-{
- typedef unique_ptr<_Tp, _Dp> argument_type;
- typedef size_t result_type;
- _LIBCPP_INLINE_VISIBILITY
- result_type operator()(const argument_type& __ptr) const
- {
- typedef typename argument_type::pointer pointer;
- return hash<pointer>()(__ptr.get());
- }
-};
-
struct __destruct_n
{
private:
@@ -2166,2023 +838,6 @@ public:
{__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
};
-template <class _Alloc>
-class __allocator_destructor
-{
- typedef _LIBCPP_NODEBUG_TYPE allocator_traits<_Alloc> __alloc_traits;
-public:
- typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::pointer pointer;
- typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::size_type size_type;
-private:
- _Alloc& __alloc_;
- size_type __s_;
-public:
- _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s)
- _NOEXCEPT
- : __alloc_(__a), __s_(__s) {}
- _LIBCPP_INLINE_VISIBILITY
- void operator()(pointer __p) _NOEXCEPT
- {__alloc_traits::deallocate(__alloc_, __p, __s_);}
-};
-
-template <class _InputIterator, class _ForwardIterator>
-_ForwardIterator
-uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- _ForwardIterator __s = __r;
- try
- {
-#endif
- for (; __f != __l; ++__f, (void) ++__r)
- ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (; __s != __r; ++__s)
- __s->~value_type();
- throw;
- }
-#endif
- return __r;
-}
-
-template <class _InputIterator, class _Size, class _ForwardIterator>
-_ForwardIterator
-uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- _ForwardIterator __s = __r;
- try
- {
-#endif
- for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
- ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (; __s != __r; ++__s)
- __s->~value_type();
- throw;
- }
-#endif
- return __r;
-}
-
-template <class _ForwardIterator, class _Tp>
-void
-uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- _ForwardIterator __s = __f;
- try
- {
-#endif
- for (; __f != __l; ++__f)
- ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (; __s != __f; ++__s)
- __s->~value_type();
- throw;
- }
-#endif
-}
-
-template <class _ForwardIterator, class _Size, class _Tp>
-_ForwardIterator
-uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
-{
- typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- _ForwardIterator __s = __f;
- try
- {
-#endif
- for (; __n > 0; ++__f, (void) --__n)
- ::new ((void*)_VSTD::addressof(*__f)) value_type(__x);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (; __s != __f; ++__s)
- __s->~value_type();
- throw;
- }
-#endif
- return __f;
-}
-
-#if _LIBCPP_STD_VER > 14
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void destroy(_ForwardIterator __first, _ForwardIterator __last) {
- for (; __first != __last; ++__first)
- _VSTD::destroy_at(_VSTD::addressof(*__first));
-}
-
-template <class _ForwardIterator, class _Size>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
- for (; __n > 0; (void)++__first, --__n)
- _VSTD::destroy_at(_VSTD::addressof(*__first));
- return __first;
-}
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
- using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
- auto __idx = __first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
- for (; __idx != __last; ++__idx)
- ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _VSTD::destroy(__first, __idx);
- throw;
- }
-#endif
-}
-
-template <class _ForwardIterator, class _Size>
-inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
- using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
- auto __idx = __first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
- for (; __n > 0; (void)++__idx, --__n)
- ::new ((void*)_VSTD::addressof(*__idx)) _Vt;
- return __idx;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _VSTD::destroy(__first, __idx);
- throw;
- }
-#endif
-}
-
-
-template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
- using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
- auto __idx = __first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
- for (; __idx != __last; ++__idx)
- ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _VSTD::destroy(__first, __idx);
- throw;
- }
-#endif
-}
-
-template <class _ForwardIterator, class _Size>
-inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
- using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
- auto __idx = __first;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
- for (; __n > 0; (void)++__idx, --__n)
- ::new ((void*)_VSTD::addressof(*__idx)) _Vt();
- return __idx;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _VSTD::destroy(__first, __idx);
- throw;
- }
-#endif
-}
-
-
-template <class _InputIt, class _ForwardIt>
-inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __first_res) {
- using _Vt = typename iterator_traits<_ForwardIt>::value_type;
- auto __idx = __first_res;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
- for (; __first != __last; (void)++__idx, ++__first)
- ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
- return __idx;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _VSTD::destroy(__first_res, __idx);
- throw;
- }
-#endif
-}
-
-template <class _InputIt, class _Size, class _ForwardIt>
-inline _LIBCPP_INLINE_VISIBILITY
-pair<_InputIt, _ForwardIt>
-uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
- using _Vt = typename iterator_traits<_ForwardIt>::value_type;
- auto __idx = __first_res;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try {
-#endif
- for (; __n > 0; ++__idx, (void)++__first, --__n)
- ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first));
- return {__first, __idx};
-#ifndef _LIBCPP_NO_EXCEPTIONS
- } catch (...) {
- _VSTD::destroy(__first_res, __idx);
- throw;
- }
-#endif
-}
-
-
-#endif // _LIBCPP_STD_VER > 14
-
-// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
-// should be sufficient for thread safety.
-// See https://bugs.llvm.org/show_bug.cgi?id=22803
-#if defined(__clang__) && __has_builtin(__atomic_add_fetch) \
- && defined(__ATOMIC_RELAXED) \
- && defined(__ATOMIC_ACQ_REL)
-# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
-#elif defined(_LIBCPP_COMPILER_GCC)
-# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
-#endif
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _Tp
-__libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT
-{
-#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
- return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED);
-#else
- return __t += 1;
-#endif
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _Tp
-__libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT
-{
-#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS)
- return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL);
-#else
- return __t -= 1;
-#endif
-}
-
-class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
- : public std::exception
-{
-public:
- bad_weak_ptr() _NOEXCEPT = default;
- bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;
- virtual ~bad_weak_ptr() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
-};
-
-_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
-void __throw_bad_weak_ptr()
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw bad_weak_ptr();
-#else
- _VSTD::abort();
-#endif
-}
-
-template<class _Tp> class _LIBCPP_TEMPLATE_VIS weak_ptr;
-
-class _LIBCPP_TYPE_VIS __shared_count
-{
- __shared_count(const __shared_count&);
- __shared_count& operator=(const __shared_count&);
-
-protected:
- long __shared_owners_;
- virtual ~__shared_count();
-private:
- virtual void __on_zero_shared() _NOEXCEPT = 0;
-
-public:
- _LIBCPP_INLINE_VISIBILITY
- explicit __shared_count(long __refs = 0) _NOEXCEPT
- : __shared_owners_(__refs) {}
-
-#if defined(_LIBCPP_BUILDING_LIBRARY) && \
- defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
- void __add_shared() _NOEXCEPT;
- bool __release_shared() _NOEXCEPT;
-#else
- _LIBCPP_INLINE_VISIBILITY
- void __add_shared() _NOEXCEPT {
- __libcpp_atomic_refcount_increment(__shared_owners_);
- }
- _LIBCPP_INLINE_VISIBILITY
- bool __release_shared() _NOEXCEPT {
- if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) {
- __on_zero_shared();
- return true;
- }
- return false;
- }
-#endif
- _LIBCPP_INLINE_VISIBILITY
- long use_count() const _NOEXCEPT {
- return __libcpp_relaxed_load(&__shared_owners_) + 1;
- }
-};
-
-class _LIBCPP_TYPE_VIS __shared_weak_count
- : private __shared_count
-{
- long __shared_weak_owners_;
-
-public:
- _LIBCPP_INLINE_VISIBILITY
- explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
- : __shared_count(__refs),
- __shared_weak_owners_(__refs) {}
-protected:
- virtual ~__shared_weak_count();
-
-public:
-#if defined(_LIBCPP_BUILDING_LIBRARY) && \
- defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
- void __add_shared() _NOEXCEPT;
- void __add_weak() _NOEXCEPT;
- void __release_shared() _NOEXCEPT;
-#else
- _LIBCPP_INLINE_VISIBILITY
- void __add_shared() _NOEXCEPT {
- __shared_count::__add_shared();
- }
- _LIBCPP_INLINE_VISIBILITY
- void __add_weak() _NOEXCEPT {
- __libcpp_atomic_refcount_increment(__shared_weak_owners_);
- }
- _LIBCPP_INLINE_VISIBILITY
- void __release_shared() _NOEXCEPT {
- if (__shared_count::__release_shared())
- __release_weak();
- }
-#endif
- void __release_weak() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- long use_count() const _NOEXCEPT {return __shared_count::use_count();}
- __shared_weak_count* lock() _NOEXCEPT;
-
- virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-private:
- virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
-};
-
-template <class _Tp, class _Dp, class _Alloc>
-class __shared_ptr_pointer
- : public __shared_weak_count
-{
- __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_;
-public:
- _LIBCPP_INLINE_VISIBILITY
- __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
- : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}
-
-#ifndef _LIBCPP_NO_RTTI
- virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
-
-private:
- virtual void __on_zero_shared() _NOEXCEPT;
- virtual void __on_zero_shared_weak() _NOEXCEPT;
-};
-
-#ifndef _LIBCPP_NO_RTTI
-
-template <class _Tp, class _Dp, class _Alloc>
-const void*
-__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT
-{
- return __t == typeid(_Dp) ? _VSTD::addressof(__data_.first().second()) : nullptr;
-}
-
-#endif // _LIBCPP_NO_RTTI
-
-template <class _Tp, class _Dp, class _Alloc>
-void
-__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT
-{
- __data_.first().second()(__data_.first().first());
- __data_.first().second().~_Dp();
-}
-
-template <class _Tp, class _Dp, class _Alloc>
-void
-__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
-{
- typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al;
- typedef allocator_traits<_Al> _ATraits;
- typedef pointer_traits<typename _ATraits::pointer> _PTraits;
-
- _Al __a(__data_.second());
- __data_.second().~_Alloc();
- __a.deallocate(_PTraits::pointer_to(*this), 1);
-}
-
-template <class _Tp, class _Alloc>
-struct __shared_ptr_emplace
- : __shared_weak_count
-{
- template<class ..._Args>
- _LIBCPP_HIDE_FROM_ABI
- explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
- : __storage_(_VSTD::move(__a))
- {
-#if _LIBCPP_STD_VER > 17
- using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
- _TpAlloc __tmp(*__get_alloc());
- allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), _VSTD::forward<_Args>(__args)...);
-#else
- ::new ((void*)__get_elem()) _Tp(_VSTD::forward<_Args>(__args)...);
-#endif
- }
-
- _LIBCPP_HIDE_FROM_ABI
- _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
-
- _LIBCPP_HIDE_FROM_ABI
- _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
-
-private:
- virtual void __on_zero_shared() _NOEXCEPT {
-#if _LIBCPP_STD_VER > 17
- using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
- _TpAlloc __tmp(*__get_alloc());
- allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem());
-#else
- __get_elem()->~_Tp();
-#endif
- }
-
- virtual void __on_zero_shared_weak() _NOEXCEPT {
- using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
- using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
- _ControlBlockAlloc __tmp(*__get_alloc());
- __storage_.~_Storage();
- allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
- pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
- }
-
- // This class implements the control block for non-array shared pointers created
- // through `std::allocate_shared` and `std::make_shared`.
- //
- // In previous versions of the library, we used a compressed pair to store
- // both the _Alloc and the _Tp. This implies using EBO, which is incompatible
- // with Allocator construction for _Tp. To allow implementing P0674 in C++20,
- // we now use a properly aligned char buffer while making sure that we maintain
- // the same layout that we had when we used a compressed pair.
- using _CompressedPair = __compressed_pair<_Alloc, _Tp>;
- struct _ALIGNAS_TYPE(_CompressedPair) _Storage {
- char __blob_[sizeof(_CompressedPair)];
-
- _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) {
- ::new ((void*)__get_alloc()) _Alloc(_VSTD::move(__a));
- }
- _LIBCPP_HIDE_FROM_ABI ~_Storage() {
- __get_alloc()->~_Alloc();
- }
- _Alloc* __get_alloc() _NOEXCEPT {
- _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
- typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair);
- _Alloc *__alloc = reinterpret_cast<_Alloc*>(__first);
- return __alloc;
- }
- _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT {
- _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_);
- typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair);
- _Tp *__elem = reinterpret_cast<_Tp*>(__second);
- return __elem;
- }
- };
-
- static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), "");
- static_assert(sizeof(_Storage) == sizeof(_CompressedPair), "");
- _Storage __storage_;
-};
-
-struct __shared_ptr_dummy_rebind_allocator_type;
-template <>
-class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
-{
-public:
- template <class _Other>
- struct rebind
- {
- typedef allocator<_Other> other;
- };
-};
-
-template<class _Tp> class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
-
-template<class _Tp, class _Up>
-struct __compatible_with
-#if _LIBCPP_STD_VER > 14
- : is_convertible<remove_extent_t<_Tp>*, remove_extent_t<_Up>*> {};
-#else
- : is_convertible<_Tp*, _Up*> {};
-#endif // _LIBCPP_STD_VER > 14
-
-#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
-# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((trivial_abi))
-#else
-# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI
-#endif
-
-template<class _Tp>
-class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr
-{
-public:
-#if _LIBCPP_STD_VER > 14
- typedef weak_ptr<_Tp> weak_type;
- typedef remove_extent_t<_Tp> element_type;
-#else
- typedef _Tp element_type;
-#endif
-
-private:
- element_type* __ptr_;
- __shared_weak_count* __cntrl_;
-
- struct __nat {int __for_bool_;};
-public:
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
- template<class _Yp>
- explicit shared_ptr(_Yp* __p,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat());
- template<class _Yp, class _Dp>
- shared_ptr(_Yp* __p, _Dp __d,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat());
- template<class _Yp, class _Dp, class _Alloc>
- shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat());
- template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d);
- template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a);
- template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr(const shared_ptr& __r) _NOEXCEPT;
- template<class _Yp>
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr(const shared_ptr<_Yp>& __r,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
- _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr(shared_ptr&& __r) _NOEXCEPT;
- template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat())
- _NOEXCEPT;
- template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
- typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat());
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template<class _Yp>
- shared_ptr(auto_ptr<_Yp>&& __r,
- typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
-#endif
- template <class _Yp, class _Dp>
- shared_ptr(unique_ptr<_Yp, _Dp>&&,
- typename enable_if
- <
- !is_lvalue_reference<_Dp>::value &&
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
- __nat
- >::type = __nat());
- template <class _Yp, class _Dp>
- shared_ptr(unique_ptr<_Yp, _Dp>&&,
- typename enable_if
- <
- is_lvalue_reference<_Dp>::value &&
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
- __nat
- >::type = __nat());
-
- ~shared_ptr();
-
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
- template<class _Yp>
- typename enable_if
- <
- __compatible_with<_Yp, element_type>::value,
- shared_ptr&
- >::type
- _LIBCPP_INLINE_VISIBILITY
- operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
- template<class _Yp>
- typename enable_if
- <
- __compatible_with<_Yp, element_type>::value,
- shared_ptr&
- >::type
- _LIBCPP_INLINE_VISIBILITY
- operator=(shared_ptr<_Yp>&& __r);
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
- template<class _Yp>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- !is_array<_Yp>::value &&
- is_convertible<_Yp*, element_type*>::value,
- shared_ptr
- >::type&
- operator=(auto_ptr<_Yp>&& __r);
-#endif
- template <class _Yp, class _Dp>
- typename enable_if
- <
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
- shared_ptr&
- >::type
- _LIBCPP_INLINE_VISIBILITY
- operator=(unique_ptr<_Yp, _Dp>&& __r);
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(shared_ptr& __r) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- void reset() _NOEXCEPT;
- template<class _Yp>
- typename enable_if
- <
- __compatible_with<_Yp, element_type>::value,
- void
- >::type
- _LIBCPP_INLINE_VISIBILITY
- reset(_Yp* __p);
- template<class _Yp, class _Dp>
- typename enable_if
- <
- __compatible_with<_Yp, element_type>::value,
- void
- >::type
- _LIBCPP_INLINE_VISIBILITY
- reset(_Yp* __p, _Dp __d);
- template<class _Yp, class _Dp, class _Alloc>
- typename enable_if
- <
- __compatible_with<_Yp, element_type>::value,
- void
- >::type
- _LIBCPP_INLINE_VISIBILITY
- reset(_Yp* __p, _Dp __d, _Alloc __a);
-
- _LIBCPP_INLINE_VISIBILITY
- element_type* get() const _NOEXCEPT {return __ptr_;}
- _LIBCPP_INLINE_VISIBILITY
- typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
- {return *__ptr_;}
- _LIBCPP_INLINE_VISIBILITY
- element_type* operator->() const _NOEXCEPT
- {
- static_assert(!_VSTD::is_array<_Tp>::value,
- "std::shared_ptr<T>::operator-> is only valid when T is not an array type.");
- return __ptr_;
- }
- _LIBCPP_INLINE_VISIBILITY
- long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;}
- _LIBCPP_INLINE_VISIBILITY
- bool unique() const _NOEXCEPT {return use_count() == 1;}
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != nullptr;}
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT
- {return __cntrl_ < __p.__cntrl_;}
- template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT
- {return __cntrl_ < __p.__cntrl_;}
- _LIBCPP_INLINE_VISIBILITY
- bool
- __owner_equivalent(const shared_ptr& __p) const
- {return __cntrl_ == __p.__cntrl_;}
-
-#if _LIBCPP_STD_VER > 14
- typename add_lvalue_reference<element_type>::type
- _LIBCPP_INLINE_VISIBILITY
- operator[](ptrdiff_t __i) const
- {
- static_assert(_VSTD::is_array<_Tp>::value,
- "std::shared_ptr<T>::operator[] is only valid when T is an array type.");
- return __ptr_[__i];
- }
-#endif
-
-#ifndef _LIBCPP_NO_RTTI
- template <class _Dp>
- _LIBCPP_INLINE_VISIBILITY
- _Dp* __get_deleter() const _NOEXCEPT
- {return static_cast<_Dp*>(__cntrl_
- ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp)))
- : nullptr);}
-#endif // _LIBCPP_NO_RTTI
-
- template<class _Yp, class _CntrlBlk>
- static shared_ptr<_Tp>
- __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT
- {
- shared_ptr<_Tp> __r;
- __r.__ptr_ = __p;
- __r.__cntrl_ = __cntrl;
- __r.__enable_weak_this(__r.__ptr_, __r.__ptr_);
- return __r;
- }
-
-private:
- template <class _Yp, bool = is_function<_Yp>::value>
- struct __shared_ptr_default_allocator
- {
- typedef allocator<_Yp> type;
- };
-
- template <class _Yp>
- struct __shared_ptr_default_allocator<_Yp, true>
- {
- typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type;
- };
-
- template <class _Yp, class _OrigPtr>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if<is_convertible<_OrigPtr*,
- const enable_shared_from_this<_Yp>*
- >::value,
- void>::type
- __enable_weak_this(const enable_shared_from_this<_Yp>* __e,
- _OrigPtr* __ptr) _NOEXCEPT
- {
- typedef typename remove_cv<_Yp>::type _RawYp;
- if (__e && __e->__weak_this_.expired())
- {
- __e->__weak_this_ = shared_ptr<_RawYp>(*this,
- const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr)));
- }
- }
-
- _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}
-
- template <class, class _Yp>
- struct __shared_ptr_default_delete
- : default_delete<_Yp> {};
-
- template <class _Yp, class _Un, size_t _Sz>
- struct __shared_ptr_default_delete<_Yp[_Sz], _Un>
- : default_delete<_Yp[]> {};
-
- template <class _Yp, class _Un>
- struct __shared_ptr_default_delete<_Yp[], _Un>
- : default_delete<_Yp[]> {};
-
- template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
- template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
-};
-
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-template<class _Tp>
-shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>;
-template<class _Tp, class _Dp>
-shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>;
-#endif
-
-template<class _Tp>
-inline
-_LIBCPP_CONSTEXPR
-shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
- : __ptr_(nullptr),
- __cntrl_(nullptr)
-{
-}
-
-template<class _Tp>
-inline
-_LIBCPP_CONSTEXPR
-shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
- : __ptr_(nullptr),
- __cntrl_(nullptr)
-{
-}
-
-template<class _Tp>
-template<class _Yp>
-shared_ptr<_Tp>::shared_ptr(_Yp* __p,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
- : __ptr_(__p)
-{
- unique_ptr<_Yp> __hold(__p);
- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
- typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__p, __shared_ptr_default_delete<_Tp, _Yp>(), _AllocT());
- __hold.release();
- __enable_weak_this(__p, __p);
-}
-
-template<class _Tp>
-template<class _Yp, class _Dp>
-shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
- : __ptr_(__p)
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
- typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
- __enable_weak_this(__p, __p);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __d(__p);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
-}
-
-template<class _Tp>
-template<class _Dp>
-shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
- : __ptr_(nullptr)
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
- typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __d(__p);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
-}
-
-template<class _Tp>
-template<class _Yp, class _Dp, class _Alloc>
-shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
- : __ptr_(__p)
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
- typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
- typedef __allocator_destructor<_A2> _D2;
- _A2 __a2(__a);
- unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
- ::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
- __cntrl_ = _VSTD::addressof(*__hold2.release());
- __enable_weak_this(__p, __p);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __d(__p);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
-}
-
-template<class _Tp>
-template<class _Dp, class _Alloc>
-shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
- : __ptr_(nullptr)
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
- typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
- typedef __allocator_destructor<_A2> _D2;
- _A2 __a2(__a);
- unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
- ::new ((void*)_VSTD::addressof(*__hold2.get())) _CntrlBlk(__p, __d, __a);
- __cntrl_ = _VSTD::addressof(*__hold2.release());
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __d(__p);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT
- : __ptr_(__p),
- __cntrl_(__r.__cntrl_)
-{
- if (__cntrl_)
- __cntrl_->__add_shared();
-}
-
-template<class _Tp>
-inline
-shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- if (__cntrl_)
- __cntrl_->__add_shared();
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
- _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- if (__cntrl_)
- __cntrl_->__add_shared();
-}
-
-template<class _Tp>
-inline
-shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- __r.__ptr_ = nullptr;
- __r.__cntrl_ = nullptr;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
- typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type)
- _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- __r.__ptr_ = nullptr;
- __r.__cntrl_ = nullptr;
-}
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-template<class _Tp>
-template<class _Yp>
-shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
- typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
- : __ptr_(__r.get())
-{
- typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>());
- __enable_weak_this(__r.get(), __r.get());
- __r.release();
-}
-#endif
-
-template<class _Tp>
-template <class _Yp, class _Dp>
-shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
- typename enable_if
- <
- !is_lvalue_reference<_Dp>::value &&
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
- __nat
- >::type)
- : __ptr_(__r.get())
-{
-#if _LIBCPP_STD_VER > 11
- if (__ptr_ == nullptr)
- __cntrl_ = nullptr;
- else
-#endif
- {
- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
- typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT());
- __enable_weak_this(__r.get(), __r.get());
- }
- __r.release();
-}
-
-template<class _Tp>
-template <class _Yp, class _Dp>
-shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
- typename enable_if
- <
- is_lvalue_reference<_Dp>::value &&
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
- __nat
- >::type)
- : __ptr_(__r.get())
-{
-#if _LIBCPP_STD_VER > 11
- if (__ptr_ == nullptr)
- __cntrl_ = nullptr;
- else
-#endif
- {
- typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
- typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
- reference_wrapper<typename remove_reference<_Dp>::type>,
- _AllocT > _CntrlBlk;
- __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
- __enable_weak_this(__r.get(), __r.get());
- }
- __r.release();
-}
-
-template<class _Tp>
-shared_ptr<_Tp>::~shared_ptr()
-{
- if (__cntrl_)
- __cntrl_->__release_shared();
-}
-
-template<class _Tp>
-inline
-shared_ptr<_Tp>&
-shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT
-{
- shared_ptr(__r).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
- shared_ptr<_Tp>&
->::type
-shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
-{
- shared_ptr(__r).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-inline
-shared_ptr<_Tp>&
-shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT
-{
- shared_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
- shared_ptr<_Tp>&
->::type
-shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)
-{
- shared_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-
-#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- !is_array<_Yp>::value &&
- is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value,
- shared_ptr<_Tp>
->::type&
-shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r)
-{
- shared_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-#endif
-
-template<class _Tp>
-template <class _Yp, class _Dp>
-inline
-typename enable_if
-<
- is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
- typename shared_ptr<_Tp>::element_type*>::value,
- shared_ptr<_Tp>&
->::type
-shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)
-{
- shared_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-inline
-void
-shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT
-{
- _VSTD::swap(__ptr_, __r.__ptr_);
- _VSTD::swap(__cntrl_, __r.__cntrl_);
-}
-
-template<class _Tp>
-inline
-void
-shared_ptr<_Tp>::reset() _NOEXCEPT
-{
- shared_ptr().swap(*this);
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
- void
->::type
-shared_ptr<_Tp>::reset(_Yp* __p)
-{
- shared_ptr(__p).swap(*this);
-}
-
-template<class _Tp>
-template<class _Yp, class _Dp>
-inline
-typename enable_if
-<
- __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
- void
->::type
-shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d)
-{
- shared_ptr(__p, __d).swap(*this);
-}
-
-template<class _Tp>
-template<class _Yp, class _Dp, class _Alloc>
-inline
-typename enable_if
-<
- __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value,
- void
->::type
-shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
-{
- shared_ptr(__p, __d, __a).swap(*this);
-}
-
-//
-// std::allocate_shared and std::make_shared
-//
-template<class _Tp, class _Alloc, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
-_LIBCPP_HIDE_FROM_ABI
-shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& ...__args)
-{
- using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
- using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
- __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);
- ::new ((void*)_VSTD::addressof(*__guard.__get())) _ControlBlock(__a, _VSTD::forward<_Args>(__args)...);
- auto __control_block = __guard.__release_ptr();
- return shared_ptr<_Tp>::__create_with_control_block((*__control_block).__get_elem(), _VSTD::addressof(*__control_block));
-}
-
-template<class _Tp, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> >
-_LIBCPP_HIDE_FROM_ABI
-shared_ptr<_Tp> make_shared(_Args&& ...__args)
-{
- return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
-{
- return __x.get() == __y.get();
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
-{
- return !(__x == __y);
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
-{
-#if _LIBCPP_STD_VER <= 11
- typedef typename common_type<_Tp*, _Up*>::type _Vp;
- return less<_Vp>()(__x.get(), __y.get());
-#else
- return less<>()(__x.get(), __y.get());
-#endif
-
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
-{
- return __y < __x;
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
-{
- return !(__y < __x);
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
-{
- return !(__x < __y);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
-{
- return !__x;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
-{
- return !__x;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
-{
- return static_cast<bool>(__x);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
-{
- return static_cast<bool>(__x);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
-{
- return less<_Tp*>()(__x.get(), nullptr);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
-{
- return less<_Tp*>()(nullptr, __x.get());
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
-{
- return nullptr < __x;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
-{
- return __x < nullptr;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
-{
- return !(nullptr < __x);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
-{
- return !(__x < nullptr);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
-{
- return !(__x < nullptr);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
-{
- return !(nullptr < __x);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT
-{
- __x.swap(__y);
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-shared_ptr<_Tp>
-static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
-{
- return shared_ptr<_Tp>(__r,
- static_cast<
- typename shared_ptr<_Tp>::element_type*>(__r.get()));
-}
-
-template<class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-shared_ptr<_Tp>
-dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
-{
- typedef typename shared_ptr<_Tp>::element_type _ET;
- _ET* __p = dynamic_cast<_ET*>(__r.get());
- return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>();
-}
-
-template<class _Tp, class _Up>
-shared_ptr<_Tp>
-const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
-{
- typedef typename shared_ptr<_Tp>::element_type _RTp;
- return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get()));
-}
-
-template<class _Tp, class _Up>
-shared_ptr<_Tp>
-reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
-{
- return shared_ptr<_Tp>(__r,
- reinterpret_cast<
- typename shared_ptr<_Tp>::element_type*>(__r.get()));
-}
-
-#ifndef _LIBCPP_NO_RTTI
-
-template<class _Dp, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_Dp*
-get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
-{
- return __p.template __get_deleter<_Dp>();
-}
-
-#endif // _LIBCPP_NO_RTTI
-
-template<class _Tp>
-class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr
-{
-public:
- typedef _Tp element_type;
-private:
- element_type* __ptr_;
- __shared_weak_count* __cntrl_;
-
-public:
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
- template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r,
- typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
- _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- weak_ptr(weak_ptr const& __r) _NOEXCEPT;
- template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r,
- typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
- _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY
- weak_ptr(weak_ptr&& __r) _NOEXCEPT;
- template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r,
- typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
- _NOEXCEPT;
- ~weak_ptr();
-
- _LIBCPP_INLINE_VISIBILITY
- weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT;
- template<class _Yp>
- typename enable_if
- <
- is_convertible<_Yp*, element_type*>::value,
- weak_ptr&
- >::type
- _LIBCPP_INLINE_VISIBILITY
- operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY
- weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
- template<class _Yp>
- typename enable_if
- <
- is_convertible<_Yp*, element_type*>::value,
- weak_ptr&
- >::type
- _LIBCPP_INLINE_VISIBILITY
- operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
-
- template<class _Yp>
- typename enable_if
- <
- is_convertible<_Yp*, element_type*>::value,
- weak_ptr&
- >::type
- _LIBCPP_INLINE_VISIBILITY
- operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY
- void swap(weak_ptr& __r) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
- void reset() _NOEXCEPT;
-
- _LIBCPP_INLINE_VISIBILITY
- long use_count() const _NOEXCEPT
- {return __cntrl_ ? __cntrl_->use_count() : 0;}
- _LIBCPP_INLINE_VISIBILITY
- bool expired() const _NOEXCEPT
- {return __cntrl_ == nullptr || __cntrl_->use_count() == 0;}
- shared_ptr<_Tp> lock() const _NOEXCEPT;
- template<class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT
- {return __cntrl_ < __r.__cntrl_;}
- template<class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT
- {return __cntrl_ < __r.__cntrl_;}
-
- template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
- template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
-};
-
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-template<class _Tp>
-weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>;
-#endif
-
-template<class _Tp>
-inline
-_LIBCPP_CONSTEXPR
-weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
- : __ptr_(nullptr),
- __cntrl_(nullptr)
-{
-}
-
-template<class _Tp>
-inline
-weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- if (__cntrl_)
- __cntrl_->__add_weak();
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
- typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
- _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- if (__cntrl_)
- __cntrl_->__add_weak();
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
- typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
- _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- if (__cntrl_)
- __cntrl_->__add_weak();
-}
-
-template<class _Tp>
-inline
-weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- __r.__ptr_ = nullptr;
- __r.__cntrl_ = nullptr;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
- typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
- _NOEXCEPT
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_)
-{
- __r.__ptr_ = nullptr;
- __r.__cntrl_ = nullptr;
-}
-
-template<class _Tp>
-weak_ptr<_Tp>::~weak_ptr()
-{
- if (__cntrl_)
- __cntrl_->__release_weak();
-}
-
-template<class _Tp>
-inline
-weak_ptr<_Tp>&
-weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT
-{
- weak_ptr(__r).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- is_convertible<_Yp*, _Tp*>::value,
- weak_ptr<_Tp>&
->::type
-weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
-{
- weak_ptr(__r).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-inline
-weak_ptr<_Tp>&
-weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT
-{
- weak_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- is_convertible<_Yp*, _Tp*>::value,
- weak_ptr<_Tp>&
->::type
-weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
-{
- weak_ptr(_VSTD::move(__r)).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-template<class _Yp>
-inline
-typename enable_if
-<
- is_convertible<_Yp*, _Tp*>::value,
- weak_ptr<_Tp>&
->::type
-weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT
-{
- weak_ptr(__r).swap(*this);
- return *this;
-}
-
-template<class _Tp>
-inline
-void
-weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT
-{
- _VSTD::swap(__ptr_, __r.__ptr_);
- _VSTD::swap(__cntrl_, __r.__cntrl_);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-void
-swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT
-{
- __x.swap(__y);
-}
-
-template<class _Tp>
-inline
-void
-weak_ptr<_Tp>::reset() _NOEXCEPT
-{
- weak_ptr().swap(*this);
-}
-
-template<class _Tp>
-template<class _Yp>
-shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
- typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
- : __ptr_(__r.__ptr_),
- __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
-{
- if (__cntrl_ == nullptr)
- __throw_bad_weak_ptr();
-}
-
-template<class _Tp>
-shared_ptr<_Tp>
-weak_ptr<_Tp>::lock() const _NOEXCEPT
-{
- shared_ptr<_Tp> __r;
- __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_;
- if (__r.__cntrl_)
- __r.__ptr_ = __ptr_;
- return __r;
-}
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp = void> struct owner_less;
-#else
-template <class _Tp> struct owner_less;
-#endif
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> >
- : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
-{
- typedef bool result_type;
- _LIBCPP_INLINE_VISIBILITY
- bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- _LIBCPP_INLINE_VISIBILITY
- bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> >
- : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
-{
- typedef bool result_type;
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- _LIBCPP_INLINE_VISIBILITY
- bool operator()(shared_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
-};
-
-#if _LIBCPP_STD_VER > 14
-template <>
-struct _LIBCPP_TEMPLATE_VIS owner_less<void>
-{
- template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- template <class _Tp, class _Up>
- _LIBCPP_INLINE_VISIBILITY
- bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const _NOEXCEPT
- {return __x.owner_before(__y);}
- typedef void is_transparent;
-};
-#endif
-
-template<class _Tp>
-class _LIBCPP_TEMPLATE_VIS enable_shared_from_this
-{
- mutable weak_ptr<_Tp> __weak_this_;
-protected:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- enable_shared_from_this() _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY
- enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY
- enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT
- {return *this;}
- _LIBCPP_INLINE_VISIBILITY
- ~enable_shared_from_this() {}
-public:
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr<_Tp> shared_from_this()
- {return shared_ptr<_Tp>(__weak_this_);}
- _LIBCPP_INLINE_VISIBILITY
- shared_ptr<_Tp const> shared_from_this() const
- {return shared_ptr<const _Tp>(__weak_this_);}
-
-#if _LIBCPP_STD_VER > 14
- _LIBCPP_INLINE_VISIBILITY
- weak_ptr<_Tp> weak_from_this() _NOEXCEPT
- { return __weak_this_; }
-
- _LIBCPP_INLINE_VISIBILITY
- weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT
- { return __weak_this_; }
-#endif // _LIBCPP_STD_VER > 14
-
- template <class _Up> friend class shared_ptr;
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> >
-{
- typedef shared_ptr<_Tp> argument_type;
- typedef size_t result_type;
-
- _LIBCPP_INLINE_VISIBILITY
- result_type operator()(const argument_type& __ptr) const _NOEXCEPT
- {
- return hash<typename shared_ptr<_Tp>::element_type*>()(__ptr.get());
- }
-};
-
-template<class _CharT, class _Traits, class _Yp>
-inline _LIBCPP_INLINE_VISIBILITY
-basic_ostream<_CharT, _Traits>&
-operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
-
-
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-
-class _LIBCPP_TYPE_VIS __sp_mut
-{
- void* __lx;
-public:
- void lock() _NOEXCEPT;
- void unlock() _NOEXCEPT;
-
-private:
- _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT;
- __sp_mut(const __sp_mut&);
- __sp_mut& operator=(const __sp_mut&);
-
- friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*);
-};
-
-_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-__sp_mut& __get_sp_mut(const void*);
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-atomic_is_lock_free(const shared_ptr<_Tp>*)
-{
- return false;
-}
-
-template <class _Tp>
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-shared_ptr<_Tp>
-atomic_load(const shared_ptr<_Tp>* __p)
-{
- __sp_mut& __m = __get_sp_mut(__p);
- __m.lock();
- shared_ptr<_Tp> __q = *__p;
- __m.unlock();
- return __q;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-shared_ptr<_Tp>
-atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
-{
- return atomic_load(__p);
-}
-
-template <class _Tp>
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-void
-atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
-{
- __sp_mut& __m = __get_sp_mut(__p);
- __m.lock();
- __p->swap(__r);
- __m.unlock();
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-void
-atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
-{
- atomic_store(__p, __r);
-}
-
-template <class _Tp>
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-shared_ptr<_Tp>
-atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
-{
- __sp_mut& __m = __get_sp_mut(__p);
- __m.lock();
- __p->swap(__r);
- __m.unlock();
- return __r;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-shared_ptr<_Tp>
-atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
-{
- return atomic_exchange(__p, __r);
-}
-
-template <class _Tp>
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-bool
-atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
-{
- shared_ptr<_Tp> __temp;
- __sp_mut& __m = __get_sp_mut(__p);
- __m.lock();
- if (__p->__owner_equivalent(*__v))
- {
- _VSTD::swap(__temp, *__p);
- *__p = __w;
- __m.unlock();
- return true;
- }
- _VSTD::swap(__temp, *__v);
- *__v = *__p;
- __m.unlock();
- return false;
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-bool
-atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
-{
- return atomic_compare_exchange_strong(__p, __v, __w);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-bool
-atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
- shared_ptr<_Tp> __w, memory_order, memory_order)
-{
- return atomic_compare_exchange_strong(__p, __v, __w);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
-bool
-atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
- shared_ptr<_Tp> __w, memory_order, memory_order)
-{
- return atomic_compare_exchange_weak(__p, __v, __w);
-}
-
-#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-
-//enum class
-#if defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE)
-# ifndef _LIBCPP_CXX03_LANG
-enum class pointer_safety : unsigned char {
- relaxed,
- preferred,
- strict
-};
-# endif
-#else
-struct _LIBCPP_TYPE_VIS pointer_safety
-{
- enum __lx
- {
- relaxed,
- preferred,
- strict
- };
-
- __lx __v_;
-
- _LIBCPP_INLINE_VISIBILITY
- pointer_safety() : __v_() {}
-
- _LIBCPP_INLINE_VISIBILITY
- pointer_safety(__lx __v) : __v_(__v) {}
- _LIBCPP_INLINE_VISIBILITY
- operator int() const {return __v_;}
-};
-#endif
-
-#if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) && \
- defined(_LIBCPP_BUILDING_LIBRARY)
-_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
-#else
-// This function is only offered in C++03 under ABI v1.
-# if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) || !defined(_LIBCPP_CXX03_LANG)
-inline _LIBCPP_INLINE_VISIBILITY
-pointer_safety get_pointer_safety() _NOEXCEPT {
- return pointer_safety::relaxed;
-}
-# endif
-#endif
-
-
-_LIBCPP_FUNC_VIS void declare_reachable(void* __p);
-_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n);
-_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n);
-_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p);
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp*
-undeclare_reachable(_Tp* __p)
-{
- return static_cast<_Tp*>(__undeclare_reachable(__p));
-}
-
_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
// --- Helper for container swap --
@@ -4213,7 +868,7 @@ void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
#endif
{
_VSTD::__swap_allocator(__a1, __a2,
- integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
+ integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>());
}
template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
@@ -4253,7 +908,7 @@ struct __is_allocator : false_type {};
template<typename _Alloc>
struct __is_allocator<_Alloc,
typename __void_t<typename _Alloc::value_type>::type,
- typename __void_t<decltype(_VSTD::declval<_Alloc&>().allocate(size_t(0)))>::type
+ typename __void_t<decltype(declval<_Alloc&>().allocate(size_t(0)))>::type
>
: true_type {};
@@ -4311,4 +966,4 @@ _LIBCPP_POP_MACROS
# include <__pstl_memory>
#endif
-#endif // _LIBCPP_MEMORY
+#endif // _LIBCPP_MEMORY
diff --git a/contrib/llvm-project/libcxx/include/module.modulemap b/contrib/llvm-project/libcxx/include/module.modulemap
index 750cd3858887..b5781b027f96 100644
--- a/contrib/llvm-project/libcxx/include/module.modulemap
+++ b/contrib/llvm-project/libcxx/include/module.modulemap
@@ -217,6 +217,102 @@ module std [system] {
header "algorithm"
export initializer_list
export *
+
+ module __algorithm {
+ module adjacent_find { private header "__algorithm/adjacent_find.h" }
+ module all_of { private header "__algorithm/all_of.h" }
+ module any_of { private header "__algorithm/any_of.h" }
+ module binary_search { private header "__algorithm/binary_search.h" }
+ module clamp { private header "__algorithm/clamp.h" }
+ module comp { private header "__algorithm/comp.h" }
+ module comp_ref_type { private header "__algorithm/comp_ref_type.h" }
+ module copy { private header "__algorithm/copy.h" }
+ module copy_backward { private header "__algorithm/copy_backward.h" }
+ module copy_if { private header "__algorithm/copy_if.h" }
+ module copy_n { private header "__algorithm/copy_n.h" }
+ module count { private header "__algorithm/count.h" }
+ module count_if { private header "__algorithm/count_if.h" }
+ module equal { private header "__algorithm/equal.h" }
+ module equal_range { private header "__algorithm/equal_range.h" }
+ module fill { private header "__algorithm/fill.h" }
+ module fill_n { private header "__algorithm/fill_n.h" }
+ module find { private header "__algorithm/find.h" }
+ module find_end { private header "__algorithm/find_end.h" }
+ module find_first_of { private header "__algorithm/find_first_of.h" }
+ module find_if { private header "__algorithm/find_if.h" }
+ module find_if_not { private header "__algorithm/find_if_not.h" }
+ module for_each { private header "__algorithm/for_each.h" }
+ module for_each_n { private header "__algorithm/for_each_n.h" }
+ module generate { private header "__algorithm/generate.h" }
+ module generate_n { private header "__algorithm/generate_n.h" }
+ module half_positive { private header "__algorithm/half_positive.h" }
+ module includes { private header "__algorithm/includes.h" }
+ module inplace_merge { private header "__algorithm/inplace_merge.h" }
+ module is_heap { private header "__algorithm/is_heap.h" }
+ module is_heap_until { private header "__algorithm/is_heap_until.h" }
+ module is_partitioned { private header "__algorithm/is_partitioned.h" }
+ module is_permutation { private header "__algorithm/is_permutation.h" }
+ module is_sorted { private header "__algorithm/is_sorted.h" }
+ module is_sorted_until { private header "__algorithm/is_sorted_until.h" }
+ module iter_swap { private header "__algorithm/iter_swap.h" }
+ module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" }
+ module lower_bound { private header "__algorithm/lower_bound.h" }
+ module make_heap { private header "__algorithm/make_heap.h" }
+ module max { private header "__algorithm/max.h" }
+ module max_element { private header "__algorithm/max_element.h" }
+ module merge { private header "__algorithm/merge.h" }
+ module min { private header "__algorithm/min.h" }
+ module min_element { private header "__algorithm/min_element.h" }
+ module minmax { private header "__algorithm/minmax.h" }
+ module minmax_element { private header "__algorithm/minmax_element.h" }
+ module mismatch { private header "__algorithm/mismatch.h" }
+ module move { private header "__algorithm/move.h" }
+ module move_backward { private header "__algorithm/move_backward.h" }
+ module next_permutation { private header "__algorithm/next_permutation.h" }
+ module none_of { private header "__algorithm/none_of.h" }
+ module nth_element { private header "__algorithm/nth_element.h" }
+ module partial_sort { private header "__algorithm/partial_sort.h" }
+ module partial_sort_copy { private header "__algorithm/partial_sort_copy.h" }
+ module partition { private header "__algorithm/partition.h" }
+ module partition_copy { private header "__algorithm/partition_copy.h" }
+ module partition_point { private header "__algorithm/partition_point.h" }
+ module pop_heap { private header "__algorithm/pop_heap.h" }
+ module prev_permutation { private header "__algorithm/prev_permutation.h" }
+ module push_heap { private header "__algorithm/push_heap.h" }
+ module remove { private header "__algorithm/remove.h" }
+ module remove_copy { private header "__algorithm/remove_copy.h" }
+ module remove_copy_if { private header "__algorithm/remove_copy_if.h" }
+ module remove_if { private header "__algorithm/remove_if.h" }
+ module replace { private header "__algorithm/replace.h" }
+ module replace_copy { private header "__algorithm/replace_copy.h" }
+ module replace_copy_if { private header "__algorithm/replace_copy_if.h" }
+ module replace_if { private header "__algorithm/replace_if.h" }
+ module reverse { private header "__algorithm/reverse.h" }
+ module reverse_copy { private header "__algorithm/reverse_copy.h" }
+ module rotate { private header "__algorithm/rotate.h" }
+ module rotate_copy { private header "__algorithm/rotate_copy.h" }
+ module sample { private header "__algorithm/sample.h" }
+ module search { private header "__algorithm/search.h" }
+ module search_n { private header "__algorithm/search_n.h" }
+ module set_difference { private header "__algorithm/set_difference.h" }
+ module set_intersection { private header "__algorithm/set_intersection.h" }
+ module set_symmetric_difference { private header "__algorithm/set_symmetric_difference.h" }
+ module set_union { private header "__algorithm/set_union.h" }
+ module shift_left { private header "__algorithm/shift_left.h" }
+ module shift_right { private header "__algorithm/shift_right.h" }
+ module shuffle { private header "__algorithm/shuffle.h" }
+ module sift_down { private header "__algorithm/sift_down.h" }
+ module sort { private header "__algorithm/sort.h" }
+ module sort_heap { private header "__algorithm/sort_heap.h" }
+ module stable_partition { private header "__algorithm/stable_partition.h" }
+ module stable_sort { private header "__algorithm/stable_sort.h" }
+ module swap_ranges { private header "__algorithm/swap_ranges.h" }
+ module transform { private header "__algorithm/transform.h" }
+ module unique { private header "__algorithm/unique.h" }
+ module unique_copy { private header "__algorithm/unique_copy.h" }
+ module unwrap_iter { private header "__algorithm/unwrap_iter.h" }
+ module upper_bound { private header "__algorithm/upper_bound.h" }
+ }
}
module any {
header "any"
@@ -292,6 +388,15 @@ module std [system] {
header "filesystem"
export *
}
+ module format {
+ header "format"
+ export *
+
+ module __format {
+ module format_error { private header "__format/format_error.h" }
+ module format_parse_context { private header "__format/format_parse_context.h" }
+ }
+ }
module forward_list {
header "forward_list"
export initializer_list
@@ -304,6 +409,34 @@ module std [system] {
module functional {
header "functional"
export *
+
+ module __functional {
+ module binary_function { private header "__functional/binary_function.h" }
+ module binary_negate { private header "__functional/binary_negate.h" }
+ module bind { private header "__functional/bind.h" }
+ module bind_front { private header "__functional/bind_front.h" }
+ module binder1st { private header "__functional/binder1st.h" }
+ module binder2nd { private header "__functional/binder2nd.h" }
+ module default_searcher { private header "__functional/default_searcher.h" }
+ module function { private header "__functional/function.h" }
+ module hash { private header "__functional/hash.h" }
+ module identity { private header "__functional/identity.h" }
+ module is_transparent { private header "__functional/is_transparent.h" }
+ module invoke { private header "__functional/invoke.h" }
+ module mem_fn { private header "__functional/mem_fn.h" }
+ module mem_fun_ref { private header "__functional/mem_fun_ref.h" }
+ module not_fn { private header "__functional/not_fn.h" }
+ module operations { private header "__functional/operations.h" }
+ module perfect_forward { private header "__functional/perfect_forward.h" }
+ module pointer_to_binary_function { private header "__functional/pointer_to_binary_function.h" }
+ module pointer_to_unary_function { private header "__functional/pointer_to_unary_function.h" }
+ module ranges_operations { private header "__functional/ranges_operations.h" }
+ module reference_wrapper { private header "__functional/reference_wrapper.h" }
+ module unary_function { private header "__functional/unary_function.h" }
+ module unary_negate { private header "__functional/unary_negate.h" }
+ module unwrap_ref { private header "__functional/unwrap_ref.h" }
+ module weak_result_type { private header "__functional/weak_result_type.h" }
+ }
}
module future {
header "future"
@@ -342,6 +475,49 @@ module std [system] {
module iterator {
header "iterator"
export *
+
+ module __iterator {
+ module access { private header "__iterator/access.h" }
+ module advance {
+ private header "__iterator/advance.h"
+ export __function_like
+ }
+ module back_insert_iterator { private header "__iterator/back_insert_iterator.h" }
+ module common_iterator { private header "__iterator/common_iterator.h" }
+ module concepts { private header "__iterator/concepts.h" }
+ module counted_iterator { private header "__iterator/counted_iterator.h" }
+ module data { private header "__iterator/data.h" }
+ module default_sentinel { private header "__iterator/default_sentinel.h" }
+ module distance { private header "__iterator/distance.h" }
+ module empty { private header "__iterator/empty.h" }
+ module erase_if_container { private header "__iterator/erase_if_container.h" }
+ module front_insert_iterator { private header "__iterator/front_insert_iterator.h" }
+ module incrementable_traits { private header "__iterator/incrementable_traits.h" }
+ module insert_iterator { private header "__iterator/insert_iterator.h" }
+ module istream_iterator { private header "__iterator/istream_iterator.h" }
+ module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" }
+ module iter_move { private header "__iterator/iter_move.h" }
+ module iter_swap { private header "__iterator/iter_swap.h" }
+ module iterator { private header "__iterator/iterator.h" }
+ module iterator_traits { private header "__iterator/iterator_traits.h" }
+ module move_iterator { private header "__iterator/move_iterator.h" }
+ module next {
+ private header "__iterator/next.h"
+ export __function_like
+ }
+ module ostream_iterator { private header "__iterator/ostream_iterator.h" }
+ module ostreambuf_iterator { private header "__iterator/ostreambuf_iterator.h" }
+ module prev {
+ private header "__iterator/prev.h"
+ export __function_like
+ }
+ module projected { private header "__iterator/projected.h" }
+ module readable_traits { private header "__iterator/readable_traits.h" }
+ module reverse_access { private header "__iterator/reverse_access.h" }
+ module reverse_iterator { private header "__iterator/reverse_iterator.h" }
+ module size { private header "__iterator/size.h" }
+ module wrap_iter { private header "__iterator/wrap_iter.h" }
+ }
}
module latch {
requires cplusplus14
@@ -369,6 +545,25 @@ module std [system] {
module memory {
header "memory"
export *
+
+ module __memory {
+ module addressof { private header "__memory/addressof.h" }
+ module allocation_guard { private header "__memory/allocation_guard.h" }
+ module allocator { private header "__memory/allocator.h" }
+ module allocator_arg_t { private header "__memory/allocator_arg_t.h" }
+ module allocator_traits { private header "__memory/allocator_traits.h" }
+ module auto_ptr { private header "__memory/auto_ptr.h" }
+ module compressed_pair { private header "__memory/compressed_pair.h" }
+ module construct_at { private header "__memory/construct_at.h" }
+ module pointer_safety { private header "__memory/pointer_safety.h" }
+ module pointer_traits { private header "__memory/pointer_traits.h" }
+ module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" }
+ module shared_ptr { private header "__memory/shared_ptr.h" }
+ module temporary_buffer { private header "__memory/temporary_buffer.h" }
+ module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" }
+ module unique_ptr { private header "__memory/unique_ptr.h" }
+ module uses_allocator { private header "__memory/uses_allocator.h" }
+ }
}
module mutex {
header "mutex"
@@ -404,6 +599,38 @@ module std [system] {
header "random"
export initializer_list
export *
+
+ module __random {
+ module uniform_int_distribution { private header "__random/uniform_int_distribution.h" }
+ }
+ }
+ module ranges {
+ header "ranges"
+ export compare
+ export initializer_list
+ export iterator
+ export *
+
+ module __ranges {
+ module access { private header "__ranges/access.h" }
+ module all { private header "__ranges/all.h" }
+ module common_view { private header "__ranges/common_view.h" }
+ module concepts { private header "__ranges/concepts.h" }
+ module copyable_box { private header "__ranges/copyable_box.h" }
+ module dangling { private header "__ranges/dangling.h" }
+ module data { private header "__ranges/data.h" }
+ module drop_view { private header "__ranges/drop_view.h" }
+ module empty { private header "__ranges/empty.h" }
+ module empty_view { private header "__ranges/empty_view.h" }
+ module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" }
+ module enable_view { private header "__ranges/enable_view.h" }
+ module non_propagating_cache { private header "__ranges/non_propagating_cache.h" }
+ module ref_view { private header "__ranges/ref_view.h" }
+ module size { private header "__ranges/size.h" }
+ module subrange { private header "__ranges/subrange.h" }
+ module transform_view { private header "__ranges/transform_view.h" }
+ module view_interface { private header "__ranges/view_interface.h" }
+ }
}
module ratio {
header "ratio"
@@ -428,6 +655,15 @@ module std [system] {
export initializer_list
export *
}
+ module shared_mutex {
+ header "shared_mutex"
+ export version
+ }
+ module span {
+ header "span"
+ export ranges.__ranges.enable_borrowed_range
+ export version
+ }
module sstream {
header "sstream"
// FIXME: should re-export istream, ostream, ios, streambuf, string?
@@ -477,6 +713,7 @@ module std [system] {
}
module type_traits {
header "type_traits"
+ export functional.__functional.unwrap_ref
export *
}
module typeindex {
@@ -501,6 +738,23 @@ module std [system] {
header "utility"
export initializer_list
export *
+
+ module __utility {
+ module __decay_copy { private header "__utility/__decay_copy.h" }
+ module as_const { private header "__utility/as_const.h" }
+ module cmp { private header "__utility/cmp.h" }
+ module declval { private header "__utility/declval.h" }
+ module exchange { private header "__utility/exchange.h" }
+ module forward { private header "__utility/forward.h" }
+ module in_place { private header "__utility/in_place.h" }
+ module integer_sequence { private header "__utility/integer_sequence.h" }
+ module move { private header "__utility/move.h" }
+ module pair { private header "__utility/pair.h" }
+ module piecewise_construct { private header "__utility/piecewise_construct.h" }
+ module rel_ops { private header "__utility/rel_ops.h" }
+ module swap { private header "__utility/swap.h" }
+ module to_underlying { private header "__utility/to_underlying.h" }
+ }
}
module valarray {
header "valarray"
@@ -510,6 +764,10 @@ module std [system] {
module variant {
header "variant"
export *
+
+ module __variant {
+ module monostate { private header "__variant/monostate.h" }
+ }
}
module vector {
header "vector"
@@ -521,23 +779,26 @@ module std [system] {
export *
}
+ // __config not modularised due to a bug in Clang
// FIXME: These should be private.
- module __bits { header "__bits" export * }
- module __bit_reference { header "__bit_reference" export * }
- module __debug { header "__debug" export * }
- module __errc { header "__errc" export * }
- module __functional_base { header "__functional_base" export * }
- module __hash_table { header "__hash_table" export * }
- module __locale { header "__locale" export * }
- module __mutex_base { header "__mutex_base" export * }
- module __split_buffer { header "__split_buffer" export * }
- module __sso_allocator { header "__sso_allocator" export * }
- module __std_stream { header "__std_stream" export * }
- module __string { header "__string" export * }
- module __tree { header "__tree" export * }
- module __tuple { header "__tuple" export * }
- module __undef_macros { header "__undef_macros" export * }
- module __node_handle { header "__node_handle" export * }
+ module __availability { private header "__availability" export * }
+ module __bit_reference { private header "__bit_reference" export * }
+ module __bits { private header "__bits" export * }
+ module __debug { header "__debug" export * }
+ module __errc { private header "__errc" export * }
+ module __function_like { private header "__function_like.h" export * }
+ module __hash_table { header "__hash_table" export * }
+ module __locale { private header "__locale" export * }
+ module __mutex_base { private header "__mutex_base" export * }
+ module __node_handle { private header "__node_handle" export * }
+ module __nullptr { header "__nullptr" export * }
+ module __split_buffer { private header "__split_buffer" export * }
+ module __std_stream { private header "__std_stream" export * }
+ module __string { private header "__string" export * }
+ module __threading_support { header "__threading_support" export * }
+ module __tree { header "__tree" export * }
+ module __tuple { private header "__tuple" export * }
+ module __undef_macros { header "__undef_macros" export * }
module experimental {
requires cplusplus11
diff --git a/contrib/llvm-project/libcxx/include/mutex b/contrib/llvm-project/libcxx/include/mutex
index f098ccba4892..eb8e54ad4421 100644
--- a/contrib/llvm-project/libcxx/include/mutex
+++ b/contrib/llvm-project/libcxx/include/mutex
@@ -188,14 +188,15 @@ template<class Callable, class ...Args>
#include <__config>
#include <__mutex_base>
+#include <__threading_support>
+#include <__utility/forward.h>
#include <cstdint>
#include <functional>
#include <memory>
#ifndef _LIBCPP_CXX03_LANG
-#include <tuple>
+# include <tuple>
#endif
#include <version>
-#include <__threading_support>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -365,7 +366,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
return __r;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _L0, class _L1>
void
@@ -469,7 +470,7 @@ void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
_VSTD::__unlock(__l2, __l3...);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 14
template <class ..._Mutexes>
@@ -568,7 +569,7 @@ template<class _Callable>
_LIBCPP_INLINE_VISIBILITY
void call_once(once_flag&, const _Callable&);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
struct _LIBCPP_TEMPLATE_VIS once_flag
{
@@ -601,7 +602,7 @@ private:
template<class _Callable>
friend
void call_once(once_flag&, const _Callable&);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
};
#ifndef _LIBCPP_CXX03_LANG
@@ -702,10 +703,10 @@ call_once(once_flag& __flag, const _Callable& __func)
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_MUTEX
+#endif // _LIBCPP_MUTEX
diff --git a/contrib/llvm-project/libcxx/include/new b/contrib/llvm-project/libcxx/include/new
index 0562cef45868..aefc08c161ca 100644
--- a/contrib/llvm-project/libcxx/include/new
+++ b/contrib/llvm-project/libcxx/include/new
@@ -86,8 +86,8 @@ void operator delete[](void* ptr, void*) noexcept;
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <cstddef>
#include <cstdlib>
#include <exception>
@@ -314,7 +314,7 @@ void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
return ::_aligned_malloc(__size, __alignment);
#else
void* __result = nullptr;
- ::posix_memalign(&__result, __alignment, __size);
+ (void)::posix_memalign(&__result, __alignment, __size);
// If posix_memalign fails, __result is unmodified so we still return `nullptr`.
return __result;
#endif
@@ -356,4 +356,4 @@ constexpr _Tp* launder(_Tp* __p) noexcept
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_NEW
+#endif // _LIBCPP_NEW
diff --git a/contrib/llvm-project/libcxx/include/numbers b/contrib/llvm-project/libcxx/include/numbers
index 38dad9955487..52c67dd35930 100644
--- a/contrib/llvm-project/libcxx/include/numbers
+++ b/contrib/llvm-project/libcxx/include/numbers
@@ -59,12 +59,12 @@ namespace std::numbers {
*/
#include <__config>
-
-#if _LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
-
+#include <concepts>
#include <type_traits>
#include <version>
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -99,22 +99,19 @@ template <class T> inline constexpr T inv_sqrt3_v = __illformed<T>{};
template <class T> inline constexpr T egamma_v = __illformed<T>{};
template <class T> inline constexpr T phi_v = __illformed<T>{};
-template <class T>
-concept __floating_point = is_floating_point_v<T>;
-
-template <__floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
-template <__floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
-template <__floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605;
-template <__floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502;
-template <__floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028;
-template <__floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772;
-template <__floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176;
-template <__floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364;
-template <__floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698;
-template <__floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872;
-template <__floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957;
-template <__floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402;
-template <__floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638;
+template <floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662;
+template <floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892;
+template <floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605;
+template <floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502;
+template <floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028;
+template <floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772;
+template <floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176;
+template <floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364;
+template <floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698;
+template <floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872;
+template <floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957;
+template <floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402;
+template <floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638;
inline constexpr double e = e_v<double>;
inline constexpr double log2e = log2e_v<double>;
@@ -136,6 +133,6 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
+#endif //_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
#endif // _LIBCPP_NUMBERS
diff --git a/contrib/llvm-project/libcxx/include/numeric b/contrib/llvm-project/libcxx/include/numeric
index 4f202bb84f70..d42cbf97e511 100644
--- a/contrib/llvm-project/libcxx/include/numeric
+++ b/contrib/llvm-project/libcxx/include/numeric
@@ -145,10 +145,11 @@ template<class T>
*/
#include <__config>
+#include <__debug>
+#include <cmath> // for isnormal
+#include <functional>
#include <iterator>
#include <limits> // for numeric_limits
-#include <functional>
-#include <cmath> // for isnormal
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -613,8 +614,8 @@ _LIBCPP_INLINE_VISIBILITY constexpr
enable_if_t<is_floating_point_v<_Fp>, _Fp>
midpoint(_Fp __a, _Fp __b) noexcept
{
- constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
- constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
+ constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
+ constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible
(__a + __b)/2 : // always correctly rounded
__fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
@@ -632,4 +633,4 @@ _LIBCPP_POP_MACROS
# include <__pstl_numeric>
#endif
-#endif // _LIBCPP_NUMERIC
+#endif // _LIBCPP_NUMERIC
diff --git a/contrib/llvm-project/libcxx/include/optional b/contrib/llvm-project/libcxx/include/optional
index 97a0bbe66ca9..118db66a4abc 100644
--- a/contrib/llvm-project/libcxx/include/optional
+++ b/contrib/llvm-project/libcxx/include/optional
@@ -69,7 +69,7 @@ namespace std {
template <class T, class U> constexpr bool operator>=(const T&, const optional<U>&);
// 23.6.9, specialized algorithms
- template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below );
+ template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below ); // constexpr in C++20
template <class T> constexpr optional<see below > make_optional(T&&);
template <class T, class... Args>
constexpr optional<T> make_optional(Args&&... args);
@@ -95,26 +95,26 @@ namespace std {
template <class U = T>
constexpr EXPLICIT optional(U &&);
template <class U>
- constexpr EXPLICIT optional(const optional<U> &);
+ EXPLICIT optional(const optional<U> &); // constexpr in C++20
template <class U>
- constexpr EXPLICIT optional(optional<U> &&);
+ EXPLICIT optional(optional<U> &&); // constexpr in C++20
// 23.6.3.2, destructor
- ~optional();
+ ~optional(); // constexpr in C++20
// 23.6.3.3, assignment
- optional &operator=(nullopt_t) noexcept;
- optional &operator=(const optional &); // constexpr in C++20
- optional &operator=(optional &&) noexcept(see below); // constexpr in C++20
- template <class U = T> optional &operator=(U &&);
- template <class U> optional &operator=(const optional<U> &);
- template <class U> optional &operator=(optional<U> &&);
- template <class... Args> T& emplace(Args &&...);
+ optional &operator=(nullopt_t) noexcept; // constexpr in C++20
+ optional &operator=(const optional &); // constexpr in C++20
+ optional &operator=(optional &&) noexcept(see below); // constexpr in C++20
+ template <class U = T> optional &operator=(U &&); // constexpr in C++20
+ template <class U> optional &operator=(const optional<U> &); // constexpr in C++20
+ template <class U> optional &operator=(optional<U> &&); // constexpr in C++20
+ template <class... Args> T& emplace(Args &&...); // constexpr in C++20
template <class U, class... Args>
- T& emplace(initializer_list<U>, Args &&...);
+ T& emplace(initializer_list<U>, Args &&...); // constexpr in C++20
// 23.6.3.4, swap
- void swap(optional &) noexcept(see below );
+ void swap(optional &) noexcept(see below ); // constexpr in C++20
// 23.6.3.5, observers
constexpr T const *operator->() const;
@@ -133,7 +133,7 @@ namespace std {
template <class U> constexpr T value_or(U &&) &&;
// 23.6.3.6, modifiers
- void reset() noexcept;
+ void reset() noexcept; // constexpr in C++20
private:
T *val; // exposition only
@@ -146,10 +146,11 @@ template<class T>
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <__debug>
#include <__functional_base>
+#include <compare>
#include <functional>
#include <initializer_list>
#include <new>
@@ -220,7 +221,7 @@ struct __optional_destruct_base<_Tp, false>
bool __engaged_;
_LIBCPP_INLINE_VISIBILITY
- ~__optional_destruct_base()
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base()
{
if (__engaged_)
__val_.~value_type();
@@ -238,7 +239,7 @@ struct __optional_destruct_base<_Tp, false>
__engaged_(true) {}
_LIBCPP_INLINE_VISIBILITY
- void reset() noexcept
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
{
if (__engaged_)
{
@@ -273,7 +274,7 @@ struct __optional_destruct_base<_Tp, true>
__engaged_(true) {}
_LIBCPP_INLINE_VISIBILITY
- void reset() noexcept
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
{
if (__engaged_)
{
@@ -318,16 +319,20 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
- void __construct(_Args&&... __args)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_Args&&... __args)
{
_LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
+#if _LIBCPP_STD_VER > 17
+ _VSTD::construct_at(_VSTD::addressof(this->__val_), _VSTD::forward<_Args>(__args)...);
+#else
::new ((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
+#endif
this->__engaged_ = true;
}
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- void __construct_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
{
if (__opt.has_value())
__construct(_VSTD::forward<_That>(__opt).__get());
@@ -335,7 +340,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- void __assign_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
{
if (this->__engaged_ == __opt.has_value())
{
@@ -393,7 +398,7 @@ struct __optional_storage_base<_Tp, true>
}
_LIBCPP_INLINE_VISIBILITY
- void reset() noexcept { __value_ = nullptr; }
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept { __value_ = nullptr; }
_LIBCPP_INLINE_VISIBILITY
constexpr bool has_value() const noexcept
@@ -409,7 +414,7 @@ struct __optional_storage_base<_Tp, true>
template <class _UArg>
_LIBCPP_INLINE_VISIBILITY
- void __construct(_UArg&& __val)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_UArg&& __val)
{
_LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
static_assert(__can_bind_reference<_UArg>(),
@@ -420,7 +425,7 @@ struct __optional_storage_base<_Tp, true>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- void __construct_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
{
if (__opt.has_value())
__construct(_VSTD::forward<_That>(__opt).__get());
@@ -428,7 +433,7 @@ struct __optional_storage_base<_Tp, true>
template <class _That>
_LIBCPP_INLINE_VISIBILITY
- void __assign_from(_That&& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
{
if (has_value() == __opt.has_value())
{
@@ -460,7 +465,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
__optional_copy_base() = default;
_LIBCPP_INLINE_VISIBILITY
- __optional_copy_base(const __optional_copy_base& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_base(const __optional_copy_base& __opt)
{
this->__construct_from(__opt);
}
@@ -491,7 +496,7 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
__optional_move_base(const __optional_move_base&) = default;
_LIBCPP_INLINE_VISIBILITY
- __optional_move_base(__optional_move_base&& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_move_base(__optional_move_base&& __opt)
noexcept(is_nothrow_move_constructible_v<value_type>)
{
this->__construct_from(_VSTD::move(__opt));
@@ -525,7 +530,7 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
__optional_copy_assign_base(__optional_copy_assign_base&&) = default;
_LIBCPP_INLINE_VISIBILITY
- __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
{
this->__assign_from(__opt);
return *this;
@@ -560,7 +565,7 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp
__optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
_LIBCPP_INLINE_VISIBILITY
- __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
noexcept(is_nothrow_move_assignable_v<value_type> &&
is_nothrow_move_constructible_v<value_type>)
{
@@ -727,7 +732,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- optional(const optional<_Up>& __v)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(const optional<_Up>& __v)
{
this->__construct_from(__v);
}
@@ -735,7 +740,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- explicit optional(const optional<_Up>& __v)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(const optional<_Up>& __v)
{
this->__construct_from(__v);
}
@@ -745,7 +750,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- optional(optional<_Up>&& __v)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(optional<_Up>&& __v)
{
this->__construct_from(_VSTD::move(__v));
}
@@ -753,13 +758,13 @@ public:
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- explicit optional(optional<_Up>&& __v)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(optional<_Up>&& __v)
{
this->__construct_from(_VSTD::move(__v));
}
_LIBCPP_INLINE_VISIBILITY
- optional& operator=(nullopt_t) noexcept
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept
{
reset();
return *this;
@@ -782,7 +787,7 @@ public:
>::value>
>
_LIBCPP_INLINE_VISIBILITY
- optional&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
operator=(_Up&& __v)
{
if (this->has_value())
@@ -797,7 +802,7 @@ public:
_CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- optional&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
operator=(const optional<_Up>& __v)
{
this->__assign_from(__v);
@@ -809,7 +814,7 @@ public:
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
- optional&
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
operator=(optional<_Up>&& __v)
{
this->__assign_from(_VSTD::move(__v));
@@ -823,7 +828,7 @@ public:
>
>
_LIBCPP_INLINE_VISIBILITY
- _Tp &
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
emplace(_Args&&... __args)
{
reset();
@@ -838,7 +843,7 @@ public:
>
>
_LIBCPP_INLINE_VISIBILITY
- _Tp &
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
emplace(initializer_list<_Up> __il, _Args&&... __args)
{
reset();
@@ -847,7 +852,7 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- void swap(optional& __opt)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(optional& __opt)
noexcept(is_nothrow_move_constructible_v<value_type> &&
is_nothrow_swappable_v<value_type>)
{
@@ -877,7 +882,7 @@ public:
add_pointer_t<value_type const>
operator->() const
{
- _LIBCPP_ASSERT(this->has_value(), "optional operator-> called for disengaged value");
+ _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
return _VSTD::addressof(this->__get());
#else
@@ -890,7 +895,7 @@ public:
add_pointer_t<value_type>
operator->()
{
- _LIBCPP_ASSERT(this->has_value(), "optional operator-> called for disengaged value");
+ _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value");
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
return _VSTD::addressof(this->__get());
#else
@@ -901,36 +906,36 @@ public:
_LIBCPP_INLINE_VISIBILITY
constexpr
const value_type&
- operator*() const&
+ operator*() const& noexcept
{
- _LIBCPP_ASSERT(this->has_value(), "optional operator* called for disengaged value");
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
return this->__get();
}
_LIBCPP_INLINE_VISIBILITY
constexpr
value_type&
- operator*() &
+ operator*() & noexcept
{
- _LIBCPP_ASSERT(this->has_value(), "optional operator* called for disengaged value");
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
return this->__get();
}
_LIBCPP_INLINE_VISIBILITY
constexpr
value_type&&
- operator*() &&
+ operator*() && noexcept
{
- _LIBCPP_ASSERT(this->has_value(), "optional operator* called for disengaged value");
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
return _VSTD::move(this->__get());
}
_LIBCPP_INLINE_VISIBILITY
constexpr
const value_type&&
- operator*() const&&
+ operator*() const&& noexcept
{
- _LIBCPP_ASSERT(this->has_value(), "optional operator* called for disengaged value");
+ _LIBCPP_ASSERT(this->has_value(), "optional operator* called on a disengaged value");
return _VSTD::move(this->__get());
}
@@ -1005,7 +1010,7 @@ public:
private:
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
- static _Up*
+ static _LIBCPP_CONSTEXPR_AFTER_CXX17 _Up*
__operator_arrow(true_type, _Up& __x)
{
return _VSTD::addressof(__x);
@@ -1029,8 +1034,8 @@ template<class T>
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() ==
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() ==
+ declval<const _Up&>()), bool>,
bool
>
operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1045,8 +1050,8 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() !=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() !=
+ declval<const _Up&>()), bool>,
bool
>
operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1061,8 +1066,8 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() <
+ declval<const _Up&>()), bool>,
bool
>
operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1077,8 +1082,8 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() >
+ declval<const _Up&>()), bool>,
bool
>
operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1093,8 +1098,8 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() <=
+ declval<const _Up&>()), bool>,
bool
>
operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1109,8 +1114,8 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() >=
+ declval<const _Up&>()), bool>,
bool
>
operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
@@ -1223,8 +1228,8 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() ==
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() ==
+ declval<const _Up&>()), bool>,
bool
>
operator==(const optional<_Tp>& __x, const _Up& __v)
@@ -1235,8 +1240,8 @@ operator==(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() ==
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() ==
+ declval<const _Up&>()), bool>,
bool
>
operator==(const _Tp& __v, const optional<_Up>& __x)
@@ -1247,8 +1252,8 @@ operator==(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() !=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() !=
+ declval<const _Up&>()), bool>,
bool
>
operator!=(const optional<_Tp>& __x, const _Up& __v)
@@ -1259,8 +1264,8 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() !=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() !=
+ declval<const _Up&>()), bool>,
bool
>
operator!=(const _Tp& __v, const optional<_Up>& __x)
@@ -1271,8 +1276,8 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() <
+ declval<const _Up&>()), bool>,
bool
>
operator<(const optional<_Tp>& __x, const _Up& __v)
@@ -1283,8 +1288,8 @@ operator<(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() <
+ declval<const _Up&>()), bool>,
bool
>
operator<(const _Tp& __v, const optional<_Up>& __x)
@@ -1295,8 +1300,8 @@ operator<(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() <=
+ declval<const _Up&>()), bool>,
bool
>
operator<=(const optional<_Tp>& __x, const _Up& __v)
@@ -1307,8 +1312,8 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() <=
+ declval<const _Up&>()), bool>,
bool
>
operator<=(const _Tp& __v, const optional<_Up>& __x)
@@ -1319,8 +1324,8 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() >
+ declval<const _Up&>()), bool>,
bool
>
operator>(const optional<_Tp>& __x, const _Up& __v)
@@ -1331,8 +1336,8 @@ operator>(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() >
+ declval<const _Up&>()), bool>,
bool
>
operator>(const _Tp& __v, const optional<_Up>& __x)
@@ -1343,8 +1348,8 @@ operator>(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() >=
+ declval<const _Up&>()), bool>,
bool
>
operator>=(const optional<_Tp>& __x, const _Up& __v)
@@ -1355,8 +1360,8 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
_EnableIf<
- is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >=
- _VSTD::declval<const _Up&>()), bool>,
+ is_convertible_v<decltype(declval<const _Tp&>() >=
+ declval<const _Up&>()), bool>,
bool
>
operator>=(const _Tp& __v, const optional<_Up>& __x)
@@ -1366,7 +1371,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_EnableIf<
is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,
void
@@ -1402,11 +1407,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<
__enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>>
>
{
- typedef optional<_Tp> argument_type;
- typedef size_t result_type;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;
+ _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
+#endif
_LIBCPP_INLINE_VISIBILITY
- result_type operator()(const argument_type& __opt) const
+ size_t operator()(const optional<_Tp>& __opt) const
{
return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0;
}
@@ -1414,8 +1421,8 @@ struct _LIBCPP_TEMPLATE_VIS hash<
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_OPTIONAL
+#endif // _LIBCPP_OPTIONAL
diff --git a/contrib/llvm-project/libcxx/include/ostream b/contrib/llvm-project/libcxx/include/ostream
index f5eb8a894607..efeaee253eb9 100644
--- a/contrib/llvm-project/libcxx/include/ostream
+++ b/contrib/llvm-project/libcxx/include/ostream
@@ -134,11 +134,11 @@ template <class Stream, class T>
*/
#include <__config>
+#include <bitset>
#include <ios>
-#include <streambuf>
-#include <locale>
#include <iterator>
-#include <bitset>
+#include <locale>
+#include <streambuf>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -165,27 +165,21 @@ public:
{ this->init(__sb); }
virtual ~basic_ostream();
protected:
-#ifndef _LIBCPP_CXX03_LANG
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream(basic_ostream&& __rhs);
// 27.7.2.3 Assign/swap
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream& operator=(basic_ostream&& __rhs);
-#endif
+
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
void swap(basic_ostream& __rhs)
{ basic_ios<char_type, traits_type>::swap(__rhs); }
-#ifndef _LIBCPP_CXX03_LANG
basic_ostream (const basic_ostream& __rhs) = delete;
basic_ostream& operator=(const basic_ostream& __rhs) = delete;
-#else
- basic_ostream (const basic_ostream& __rhs); // not defined
- basic_ostream& operator=(const basic_ostream& __rhs); // not defined
-#endif
-public:
+public:
// 27.7.2.4 Prefix/suffix:
class _LIBCPP_TEMPLATE_VIS sentry;
@@ -254,8 +248,7 @@ public:
~sentry();
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT
- operator bool() const {return __ok_;}
+ explicit operator bool() const {return __ok_;}
};
template <class _CharT, class _Traits>
@@ -280,7 +273,7 @@ basic_ostream<_CharT, _Traits>::sentry::~sentry()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (__os_.rdbuf()->pubsync() == -1)
__os_.setstate(ios_base::badbit);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -288,12 +281,10 @@ basic_ostream<_CharT, _Traits>::sentry::~sentry()
catch (...)
{
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
{
@@ -308,8 +299,6 @@ basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>::~basic_ostream()
{
@@ -322,7 +311,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -331,7 +320,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
_Ip __i(__sb);
@@ -352,7 +341,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
{
this->__set_failbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
else
this->setstate(ios_base::badbit);
@@ -363,7 +352,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -374,7 +363,7 @@ basic_ostream<_CharT, _Traits>::operator<<(bool __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -389,7 +378,7 @@ basic_ostream<_CharT, _Traits>::operator<<(bool __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -400,7 +389,7 @@ basic_ostream<_CharT, _Traits>::operator<<(short __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -419,7 +408,7 @@ basic_ostream<_CharT, _Traits>::operator<<(short __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -430,7 +419,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -445,7 +434,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -456,7 +445,7 @@ basic_ostream<_CharT, _Traits>::operator<<(int __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -475,7 +464,7 @@ basic_ostream<_CharT, _Traits>::operator<<(int __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -486,7 +475,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -501,7 +490,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -512,7 +501,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -527,7 +516,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -538,7 +527,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -553,7 +542,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -564,7 +553,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long long __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -579,7 +568,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long long __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -590,7 +579,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -605,7 +594,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -616,7 +605,7 @@ basic_ostream<_CharT, _Traits>::operator<<(float __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -631,7 +620,7 @@ basic_ostream<_CharT, _Traits>::operator<<(float __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -642,7 +631,7 @@ basic_ostream<_CharT, _Traits>::operator<<(double __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -657,7 +646,7 @@ basic_ostream<_CharT, _Traits>::operator<<(double __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -668,7 +657,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long double __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -683,7 +672,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long double __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -694,7 +683,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -709,7 +698,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -721,7 +710,7 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
@@ -742,7 +731,7 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
{
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __os;
}
@@ -761,7 +750,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
@@ -783,7 +772,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
{
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __os;
}
@@ -822,7 +811,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
@@ -857,7 +846,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
{
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return __os;
}
@@ -891,7 +880,7 @@ basic_ostream<_CharT, _Traits>::put(char_type __c)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __s(*this);
if (__s)
{
@@ -907,7 +896,7 @@ basic_ostream<_CharT, _Traits>::put(char_type __c)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -918,7 +907,7 @@ basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
sentry __sen(*this);
if (__sen && __n)
{
@@ -931,7 +920,7 @@ basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -942,7 +931,7 @@ basic_ostream<_CharT, _Traits>::flush()
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf())
{
sentry __s(*this);
@@ -958,7 +947,7 @@ basic_ostream<_CharT, _Traits>::flush()
{
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -1025,19 +1014,17 @@ flush(basic_ostream<_CharT, _Traits>& __os)
return __os;
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Stream, class _Tp, class = void>
struct __is_ostreamable : false_type { };
template <class _Stream, class _Tp>
struct __is_ostreamable<_Stream, _Tp, decltype(
- _VSTD::declval<_Stream>() << _VSTD::declval<_Tp>(), void()
+ declval<_Stream>() << declval<_Tp>(), void()
)> : true_type { };
template <class _Stream, class _Tp, class = typename enable_if<
_And<is_base_of<ios_base, _Stream>,
- __is_ostreamable<_Stream&, const _Tp&>>::value
+ __is_ostreamable<_Stream&, const _Tp&> >::value
>::type>
_LIBCPP_INLINE_VISIBILITY
_Stream&& operator<<(_Stream&& __os, const _Tp& __x)
@@ -1046,8 +1033,6 @@ _Stream&& operator<<(_Stream&& __os, const _Tp& __x)
return _VSTD::move(__os);
}
-#endif // _LIBCPP_CXX03_LANG
-
template<class _CharT, class _Traits, class _Allocator>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
@@ -1106,4 +1091,4 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wch
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_OSTREAM
+#endif // _LIBCPP_OSTREAM
diff --git a/contrib/llvm-project/libcxx/include/queue b/contrib/llvm-project/libcxx/include/queue
index a2048c1e22cc..42470e3a1022 100644
--- a/contrib/llvm-project/libcxx/include/queue
+++ b/contrib/llvm-project/libcxx/include/queue
@@ -179,10 +179,13 @@ template <class T, class Container, class Compare>
*/
#include <__config>
+#include <__memory/uses_allocator.h>
+#include <__utility/forward.h>
+#include <algorithm>
+#include <compare>
#include <deque>
-#include <vector>
#include <functional>
-#include <algorithm>
+#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -238,47 +241,42 @@ public:
queue& operator=(queue&& __q)
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
{c = _VSTD::move(__q.c); return *this;}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit queue(const container_type& __c) : c(__c) {}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit queue(const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(__a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
queue(const queue& __q, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(__q.c, __a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
queue(const container_type& __c, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(__c, __a) {}
#ifndef _LIBCPP_CXX03_LANG
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
queue(container_type&& __c, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(_VSTD::move(__c), __a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
queue(queue&& __q, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(_VSTD::move(__q.c), __a) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
@@ -308,7 +306,7 @@ public:
void emplace(_Args&&... __args)
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);}
#endif
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void pop() {c.pop_front();}
@@ -335,15 +333,15 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _Container,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
+ class = _EnableIf<!__is_allocator<_Container>::value>
>
queue(_Container)
-> queue<typename _Container::value_type, _Container>;
template<class _Container,
class _Alloc,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
- class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
+ class = _EnableIf<!__is_allocator<_Container>::value>,
+ class = _EnableIf<uses_allocator<_Container, _Alloc>::value>
>
queue(_Container, _Alloc)
-> queue<typename _Container::value_type, _Container>;
@@ -399,10 +397,7 @@ operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
template <class _Tp, class _Container>
inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<
- __is_swappable<_Container>::value,
- void
->::type
+_EnableIf<__is_swappable<_Container>::value, void>
swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
@@ -458,7 +453,7 @@ public:
_NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
is_nothrow_move_assignable<value_compare>::value)
{c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit priority_queue(const value_compare& __comp)
@@ -482,41 +477,35 @@ public:
_LIBCPP_INLINE_VISIBILITY
priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp, container_type&& __c);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit priority_queue(const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0);
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
priority_queue(const value_compare& __comp, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0);
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
priority_queue(const value_compare& __comp, const container_type& __c,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0);
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
priority_queue(const priority_queue& __q, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0);
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
#ifndef _LIBCPP_CXX03_LANG
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
priority_queue(const value_compare& __comp, container_type&& __c,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0);
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
priority_queue(priority_queue&& __q, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0);
-#endif // _LIBCPP_CXX03_LANG
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
@@ -533,7 +522,7 @@ public:
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
void emplace(_Args&&... __args);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void pop();
@@ -546,28 +535,28 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template <class _Compare,
class _Container,
- class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
+ class = _EnableIf<!__is_allocator<_Compare>::value>,
+ class = _EnableIf<!__is_allocator<_Container>::value>
>
priority_queue(_Compare, _Container)
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
template<class _InputIterator,
- class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
- class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
- class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type,
- class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Container = vector<__iter_value_type<_InputIterator>>,
+ class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>,
+ class = _EnableIf<!__is_allocator<_Compare>::value>,
+ class = _EnableIf<!__is_allocator<_Container>::value>
>
priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
- -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
+ -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
template<class _Compare,
class _Container,
class _Alloc,
- class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
- class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
+ class = _EnableIf<!__is_allocator<_Compare>::value>,
+ class = _EnableIf<!__is_allocator<_Container>::value>,
+ class = _EnableIf<uses_allocator<_Container, _Alloc>::value>
>
priority_queue(_Compare, _Container, _Alloc)
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
@@ -595,7 +584,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _
_VSTD::make_heap(c.begin(), c.end(), comp);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare>
template <class _InputIter>
@@ -636,14 +625,13 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input
_VSTD::make_heap(c.begin(), c.end(), comp);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type*)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
: c(__a)
{
}
@@ -653,8 +641,7 @@ template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type*)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
: c(__a),
comp(__comp)
{
@@ -666,8 +653,7 @@ inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
const container_type& __c,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type*)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
: c(__c, __a),
comp(__comp)
{
@@ -679,8 +665,7 @@ template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type*)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
: c(__q.c, __a),
comp(__q.comp)
{
@@ -695,8 +680,7 @@ inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
container_type&& __c,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type*)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
: c(_VSTD::move(__c), __a),
comp(__comp)
{
@@ -708,15 +692,14 @@ template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type*)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
: c(_VSTD::move(__q.c), __a),
comp(_VSTD::move(__q.comp))
{
_VSTD::make_heap(c.begin(), c.end(), comp);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare>
inline
@@ -748,7 +731,7 @@ priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
_VSTD::push_heap(c.begin(), c.end(), comp);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Container, class _Compare>
inline
@@ -773,11 +756,10 @@ priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
template <class _Tp, class _Container, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<
- __is_swappable<_Container>::value
- && __is_swappable<_Compare>::value,
+_EnableIf<
+ __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
void
->::type
+>
swap(priority_queue<_Tp, _Container, _Compare>& __x,
priority_queue<_Tp, _Container, _Compare>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
@@ -793,4 +775,4 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Comp
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_QUEUE
+#endif // _LIBCPP_QUEUE
diff --git a/contrib/llvm-project/libcxx/include/random b/contrib/llvm-project/libcxx/include/random
index 6e0d2ecb47c0..4a8c2a79267b 100644
--- a/contrib/llvm-project/libcxx/include/random
+++ b/contrib/llvm-project/libcxx/include/random
@@ -17,6 +17,9 @@
namespace std
{
+// [rand.req.urng], uniform random bit generator requirements
+template<class G>
+concept uniform_random_bit_generator = see below; // C++20
// Engines
@@ -1675,17 +1678,19 @@ class piecewise_linear_distribution
*/
#include <__config>
+#include <__random/uniform_int_distribution.h>
+#include <algorithm>
+#include <cmath>
+#include <concepts>
#include <cstddef>
#include <cstdint>
-#include <cmath>
-#include <type_traits>
#include <initializer_list>
+#include <iosfwd>
#include <limits>
-#include <algorithm>
#include <numeric>
-#include <vector>
#include <string>
-#include <iosfwd>
+#include <type_traits>
+#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -1697,6 +1702,20 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
+// [rand.req.urng]
+template<class _Gen>
+concept uniform_random_bit_generator =
+ invocable<_Gen&> && unsigned_integral<invoke_result_t<_Gen&>> &&
+ requires {
+ { _Gen::min() } -> same_as<invoke_result_t<_Gen&>>;
+ { _Gen::max() } -> same_as<invoke_result_t<_Gen&>>;
+ requires bool_constant<(_Gen::min() < _Gen::max())>::value;
+ };
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
// __is_seed_sequence
template <class _Sseq, class _Engine>
@@ -1712,7 +1731,7 @@ struct __is_seed_sequence
template <unsigned long long __a, unsigned long long __c,
unsigned long long __m, unsigned long long _Mp,
bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a),
- bool _OverflowOK = ((__m|__m-1) > __m), // m = 2^n
+ bool _OverflowOK = ((__m | (__m-1)) > __m), // m = 2^n
bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q
struct __lce_alg_picker
{
@@ -1901,7 +1920,7 @@ private:
static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");
static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
- static_assert(_VSTD::is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");
+ static_assert(is_unsigned<_UIntType>::value, "_UIntType must be unsigned type");
public:
static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;
static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;
@@ -2940,7 +2959,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit discard_block_engine(_Engine&& __e)
: __e_(_VSTD::move(__e)), __n_(0) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
template<class _Sseq>
@@ -3152,7 +3171,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit independent_bits_engine(_Engine&& __e)
: __e_(_VSTD::move(__e)) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit independent_bits_engine(result_type __sd) : __e_(__sd) {}
template<class _Sseq>
@@ -3382,7 +3401,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit shuffle_order_engine(_Engine&& __e)
: __e_(_VSTD::move(__e)) {__init();}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();}
template<class _Sseq>
@@ -3634,7 +3653,7 @@ public:
template<class _Tp>
_LIBCPP_INLINE_VISIBILITY
seed_seq(initializer_list<_Tp> __il) {init(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
@@ -3755,42 +3774,6 @@ generate_canonical(_URNG& __g)
return _Sp / __base;
}
-// uniform_int_distribution
-
-// in <algorithm>
-
-template <class _CharT, class _Traits, class _IT>
-basic_ostream<_CharT, _Traits>&
-operator<<(basic_ostream<_CharT, _Traits>& __os,
- const uniform_int_distribution<_IT>& __x)
-{
- __save_flags<_CharT, _Traits> __lx(__os);
- typedef basic_ostream<_CharT, _Traits> _Ostream;
- __os.flags(_Ostream::dec | _Ostream::left);
- _CharT __sp = __os.widen(' ');
- __os.fill(__sp);
- return __os << __x.a() << __sp << __x.b();
-}
-
-template <class _CharT, class _Traits, class _IT>
-basic_istream<_CharT, _Traits>&
-operator>>(basic_istream<_CharT, _Traits>& __is,
- uniform_int_distribution<_IT>& __x)
-{
- typedef uniform_int_distribution<_IT> _Eng;
- typedef typename _Eng::result_type result_type;
- typedef typename _Eng::param_type param_type;
- __save_flags<_CharT, _Traits> __lx(__is);
- typedef basic_istream<_CharT, _Traits> _Istream;
- __is.flags(_Istream::dec | _Istream::skipws);
- result_type __a;
- result_type __b;
- __is >> __a >> __b;
- if (!__is.fail())
- __x.param(param_type(__a, __b));
- return __is;
-}
-
// uniform_real_distribution
template<class _RealType = double>
@@ -4142,7 +4125,7 @@ inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) {
}
template<class _IntType>
-binomial_distribution<_IntType>::param_type::param_type(const result_type __t, const double __p)
+binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p)
: __t_(__t), __p_(__p)
{
if (0 < __p_ && __p_ < 1)
@@ -6145,7 +6128,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
param_type(initializer_list<double> __wl)
: __p_(__wl.begin(), __wl.end()) {__init();}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(size_t __nw, double __xmin, double __xmax,
_UnaryOperation __fw);
@@ -6192,7 +6175,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
discrete_distribution(initializer_list<double> __wl)
: __p_(__wl) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
_LIBCPP_INLINE_VISIBILITY
discrete_distribution(size_t __nw, double __xmin, double __xmax,
@@ -6274,8 +6257,7 @@ discrete_distribution<_IntType>::param_type::__init()
if (__p_.size() > 1)
{
double __s = _VSTD::accumulate(__p_.begin(), __p_.end(), 0.0);
- for (_VSTD::vector<double>::iterator __i = __p_.begin(), __e = __p_.end();
- __i < __e; ++__i)
+ for (vector<double>::iterator __i = __p_.begin(), __e = __p_.end(); __i < __e; ++__i)
*__i /= __s;
vector<double> __t(__p_.size() - 1);
_VSTD::partial_sum(__p_.begin(), __p_.end() - 1, __t.begin());
@@ -6294,7 +6276,7 @@ vector<double>
discrete_distribution<_IntType>::param_type::probabilities() const
{
size_t __n = __p_.size();
- _VSTD::vector<double> __p(__n+1);
+ vector<double> __p(__n+1);
_VSTD::adjacent_difference(__p_.begin(), __p_.end(), __p.begin());
if (__n > 0)
__p[__n] = 1 - __p_[__n-1];
@@ -6374,7 +6356,7 @@ public:
#ifndef _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(size_t __nw, result_type __xmin, result_type __xmax,
_UnaryOperation __fw);
@@ -6431,7 +6413,7 @@ public:
piecewise_constant_distribution(initializer_list<result_type> __bl,
_UnaryOperation __fw)
: __p_(__bl, __fw) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
_LIBCPP_INLINE_VISIBILITY
@@ -6586,7 +6568,7 @@ piecewise_constant_distribution<_RealType>::param_type::param_type(
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _RealType>
template<class _UnaryOperation>
@@ -6700,7 +6682,7 @@ public:
#ifndef _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
param_type(size_t __nw, result_type __xmin, result_type __xmax,
_UnaryOperation __fw);
@@ -6757,7 +6739,7 @@ public:
piecewise_linear_distribution(initializer_list<result_type> __bl,
_UnaryOperation __fw)
: __p_(__bl, __fw) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _UnaryOperation>
_LIBCPP_INLINE_VISIBILITY
@@ -6916,7 +6898,7 @@ piecewise_linear_distribution<_RealType>::param_type::param_type(
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template<class _RealType>
template<class _UnaryOperation>
@@ -7022,4 +7004,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_RANDOM
+#endif // _LIBCPP_RANDOM
diff --git a/contrib/llvm-project/libcxx/include/ranges b/contrib/llvm-project/libcxx/include/ranges
new file mode 100644
index 000000000000..47f66fd3f622
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/ranges
@@ -0,0 +1,207 @@
+// -*- C++ -*-
+//===--------------------------- ranges -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_RANGES
+#define _LIBCPP_RANGES
+
+/*
+
+#include <compare> // see [compare.syn]
+#include <initializer_list> // see [initializer.list.syn]
+#include <iterator> // see [iterator.synopsis]
+
+namespace std::ranges {
+ inline namespace unspecified {
+ // [range.access], range access
+ inline constexpr unspecified begin = unspecified;
+ inline constexpr unspecified end = unspecified;
+ inline constexpr unspecified cbegin = unspecified;
+ inline constexpr unspecified cend = unspecified;
+
+ inline constexpr unspecified size = unspecified;
+ inline constexpr unspecified ssize = unspecified;
+ }
+
+ // [range.range], ranges
+ template<class T>
+ concept range = see below;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range = false;
+
+ template<class T>
+ using iterator_t = decltype(ranges::begin(declval<R&>()));
+ template<range R>
+ using sentinel_t = decltype(ranges::end(declval<R&>()));
+ template<range R>
+ using range_difference_t = iter_difference_t<iterator_t<R>>;
+ template<sized_range R>
+ using range_size_t = decltype(ranges::size(declval<R&>()));
+ template<range R>
+ using range_value_t = iter_value_t<iterator_t<R>>;
+ template<range R>
+ using range_reference_t = iter_reference_t<iterator_t<R>>;
+ template<range R>
+ using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<R>>;
+
+ // [range.sized], sized ranges
+ template<class>
+ inline constexpr bool disable_sized_range = false;
+
+ template<class T>
+ concept sized_range = ...;
+
+ // [range.view], views
+ template<class T>
+ inline constexpr bool enable_view = ...;
+
+ struct view_base { };
+
+ template<class T>
+ concept view = ...;
+
+ // [range.refinements], other range refinements
+ template<class R, class T>
+ concept output_range = see below;
+
+ template<class T>
+ concept input_range = see below;
+
+ template<class T>
+ concept forward_range = see below;
+
+ template<class T>
+ concept bidirectional_range = see below;
+
+ template<class T>
+ concept random_access_range = see below;
+
+ template<class T>
+ concept contiguous_range = see below;
+
+ template <class _Tp>
+ concept common_range = see below;
+
+ template<class T>
+ concept viewable_range = see below;
+
+ // [view.interface], class template view_interface
+ template<class D>
+ requires is_class_v<D> && same_as<D, remove_cv_t<D>>
+ class view_interface;
+
+ // [range.subrange], sub-ranges
+ enum class subrange_kind : bool { unsized, sized };
+
+ template<input_or_output_iterator I, sentinel_for<I> S = I, subrange_kind K = see below>
+ requires (K == subrange_kind::sized || !sized_sentinel_for<S, I>)
+ class subrange;
+
+ template<class I, class S, subrange_kind K>
+ inline constexpr bool enable_borrowed_range<subrange<I, S, K>> = true;
+
+ // [range.dangling], dangling iterator handling
+ struct dangling;
+
+ template<range R>
+ using borrowed_iterator_t = see below;
+
+ template<range R>
+ using borrowed_subrange_t = see below;
+
+ // [range.empty], empty view
+ template<class T>
+ requires is_object_v<T>
+ class empty_view;
+
+ // [range.all], all view
+ namespace views {
+ inline constexpr unspecified all = unspecified;
+
+ template<viewable_range R>
+ using all_t = decltype(all(declval<R>()));
+ }
+
+ template<range R>
+ requires is_object_v<R>
+ class ref_view;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<ref_view<T>> = true;
+
+ // [range.drop], drop view
+ template<view V>
+ class drop_view;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;
+
+ // [range.transform], transform view
+ template<input_range V, copy_constructible F>
+ requires view<V> && is_object_v<F> &&
+ regular_invocable<F&, range_reference_t<V>> &&
+ can-reference<invoke_result_t<F&, range_reference_t<V>>>
+ class transform_view;
+
+ // [range.common], common view
+ template<view V>
+ requires (!common_range<V> && copyable<iterator_t<V>>)
+ class common_view;
+
+ template<class T>
+ inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>;
+}
+
+*/
+
+#include <__config>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/common_view.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__ranges/data.h>
+#include <__ranges/drop_view.h>
+#include <__ranges/empty.h>
+#include <__ranges/empty_view.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
+#include <__ranges/ref_view.h>
+#include <__ranges/size.h>
+#include <__ranges/subrange.h>
+#include <__ranges/transform_view.h>
+#include <__ranges/view_interface.h>
+#include <compare> // Required by the standard.
+#include <initializer_list> // Required by the standard.
+#include <iterator> // Required by the standard.
+#include <type_traits>
+#include <version>
+
+#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+# error "The Ranges library is not supported since libc++ has been configured with LIBCXX_ENABLE_INCOMPLETE_FEATURES disabled"
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_RANGES
diff --git a/contrib/llvm-project/libcxx/include/ratio b/contrib/llvm-project/libcxx/include/ratio
index fa7a4bbb2fac..091ea53accce 100644
--- a/contrib/llvm-project/libcxx/include/ratio
+++ b/contrib/llvm-project/libcxx/include/ratio
@@ -78,8 +78,8 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
*/
#include <__config>
-#include <cstdint>
#include <climits>
+#include <cstdint>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -312,7 +312,7 @@ template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_multiply
: public __ratio_multiply<_R1, _R2>::type {};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct __ratio_divide
@@ -339,7 +339,7 @@ template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_divide
: public __ratio_divide<_R1, _R2>::type {};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct __ratio_add
@@ -374,7 +374,7 @@ template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_add
: public __ratio_add<_R1, _R2>::type {};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _R1, class _R2>
struct __ratio_subtract
@@ -409,7 +409,7 @@ template <class _R1, class _R2>
struct _LIBCPP_TEMPLATE_VIS ratio_subtract
: public __ratio_subtract<_R1, _R2>::type {};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// ratio_equal
@@ -529,4 +529,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_RATIO
+#endif // _LIBCPP_RATIO
diff --git a/contrib/llvm-project/libcxx/include/regex b/contrib/llvm-project/libcxx/include/regex
index d78e4888a619..e47cf9fca5d2 100644
--- a/contrib/llvm-project/libcxx/include/regex
+++ b/contrib/llvm-project/libcxx/include/regex
@@ -763,15 +763,18 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
*/
#include <__config>
-#include <stdexcept>
+#include <__debug>
+#include <__iterator/wrap_iter.h>
#include <__locale>
+#include <compare>
+#include <deque>
#include <initializer_list>
-#include <utility>
#include <iterator>
-#include <string>
#include <memory>
+#include <stdexcept>
+#include <string>
+#include <utility>
#include <vector>
-#include <deque>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -2000,14 +2003,14 @@ class __l_anchor_multiline
{
typedef __owns_one_state<_CharT> base;
- bool __multiline;
+ bool __multiline_;
public:
typedef _VSTD::__state<_CharT> __state;
_LIBCPP_INLINE_VISIBILITY
__l_anchor_multiline(bool __multiline, __node<_CharT>* __s)
- : base(__s), __multiline(__multiline) {}
+ : base(__s), __multiline_(__multiline) {}
virtual void __exec(__state&) const;
};
@@ -2022,7 +2025,7 @@ __l_anchor_multiline<_CharT>::__exec(__state& __s) const
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
}
- else if (__multiline &&
+ else if (__multiline_ &&
!__s.__at_first_ &&
__is_eol(*_VSTD::prev(__s.__current_)))
{
@@ -2634,7 +2637,7 @@ public:
{
__init(__il.begin(), __il.end());
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// ~basic_regex() = default;
@@ -2647,7 +2650,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_regex& operator=(initializer_list<value_type> __il)
{return assign(__il);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _ST, class _SA>
_LIBCPP_INLINE_VISIBILITY
basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
@@ -2721,7 +2724,7 @@ public:
flag_type __f = regex_constants::ECMAScript)
{return assign(__il.begin(), __il.end(), __f);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// const operations:
_LIBCPP_INLINE_VISIBILITY
@@ -4571,7 +4574,7 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
if (__hd == -1)
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
- // drop through
+ // fallthrough
case 'x':
++__first;
if (__first == __last)
@@ -5882,7 +5885,6 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
{
vector<__state> __states;
__state __best_state;
- ptrdiff_t __j = 0;
ptrdiff_t __highest_j = 0;
ptrdiff_t _Np = _VSTD::distance(__first, __last);
__node* __st = __start_.get();
@@ -5903,7 +5905,6 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
__states.back().__node_ = __st;
__states.back().__flags_ = __flags;
__states.back().__at_first_ = __at_first;
- const _CharT* __current = __first;
bool __matched = false;
int __counter = 0;
int __length = __last - __first;
@@ -5943,9 +5944,6 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
__states.pop_back();
break;
case __state::__accept_and_consume:
- __j += __s.__current_ - __current;
- __current = __s.__current_;
- break;
case __state::__repeat:
case __state::__accept_but_not_consume:
break;
@@ -6442,7 +6440,7 @@ public:
regex_constants::match_flag_type __m =
regex_constants::match_default) = delete;
#endif
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <size_t _Np>
regex_token_iterator(_BidirectionalIterator __a,
_BidirectionalIterator __b,
@@ -6557,7 +6555,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
__init(__a, __b);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _BidirectionalIterator, class _CharT, class _Traits>
template <size_t _Np>
@@ -6774,4 +6772,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_REGEX
+#endif // _LIBCPP_REGEX
diff --git a/contrib/llvm-project/libcxx/include/scoped_allocator b/contrib/llvm-project/libcxx/include/scoped_allocator
index 237cd428d111..dc24d30b510f 100644
--- a/contrib/llvm-project/libcxx/include/scoped_allocator
+++ b/contrib/llvm-project/libcxx/include/scoped_allocator
@@ -106,6 +106,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
*/
#include <__config>
+#include <__utility/forward.h>
#include <memory>
#include <version>
@@ -375,7 +376,7 @@ struct __outermost<_Alloc, true>
{
typedef typename remove_reference
<
- decltype(_VSTD::declval<_Alloc>().outer_allocator())
+ decltype(declval<_Alloc>().outer_allocator())
>::type _OuterAlloc;
typedef typename __outermost<_OuterAlloc>::type type;
_LIBCPP_INLINE_VISIBILITY
@@ -676,8 +677,8 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
return !(__a == __b);
}
-#endif // !defined(_LIBCPP_CXX03_LANG)
+#endif // !defined(_LIBCPP_CXX03_LANG)
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_SCOPED_ALLOCATOR
+#endif // _LIBCPP_SCOPED_ALLOCATOR
diff --git a/contrib/llvm-project/libcxx/include/semaphore b/contrib/llvm-project/libcxx/include/semaphore
index 0e0434f7fbd5..906f62e0f07a 100644
--- a/contrib/llvm-project/libcxx/include/semaphore
+++ b/contrib/llvm-project/libcxx/include/semaphore
@@ -45,8 +45,8 @@ using binary_semaphore = counting_semaphore<1>;
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <__threading_support>
#include <atomic>
@@ -98,7 +98,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void acquire()
{
- auto const __test_fn = [=]() -> bool {
+ auto const __test_fn = [this]() -> bool {
auto __old = __a.load(memory_order_relaxed);
return (__old != 0) && __a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed);
};
@@ -108,7 +108,7 @@ public:
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
{
- auto const __test_fn = [=]() -> bool {
+ auto const __test_fn = [this]() -> bool {
auto __old = __a.load(memory_order_acquire);
while(1) {
if (__old == 0)
diff --git a/contrib/llvm-project/libcxx/include/set b/contrib/llvm-project/libcxx/include/set
index d58455bfe219..21ec8435dd84 100644
--- a/contrib/llvm-project/libcxx/include/set
+++ b/contrib/llvm-project/libcxx/include/set
@@ -154,10 +154,14 @@ public:
iterator find(const K& x);
template<typename K>
const_iterator find(const K& x) const; // C++14
+
template<typename K>
size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
- bool contains(const key_type& x) const; // C++20
+
+ bool contains(const key_type& x) const; // C++20
+ template<class K> bool contains(const K& x) const; // C++20
+
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -355,10 +359,14 @@ public:
iterator find(const K& x);
template<typename K>
const_iterator find(const K& x) const; // C++14
+
template<typename K>
size_type count(const K& x) const; // C++14
size_type count(const key_type& k) const;
- bool contains(const key_type& x) const; // C++20
+
+ bool contains(const key_type& x) const; // C++20
+ template<class K> bool contains(const K& x) const; // C++20
+
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -426,9 +434,15 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
*/
#include <__config>
-#include <__tree>
+#include <__debug>
+#include <__functional/is_transparent.h>
#include <__node_handle>
+#include <__tree>
+#include <__utility/forward.h>
+#include <compare>
#include <functional>
+#include <initializer_list>
+#include <iterator> // __libcpp_erase_if_container
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -450,7 +464,7 @@ public:
typedef key_type value_type;
typedef _Compare key_compare;
typedef key_compare value_compare;
- typedef typename __identity<_Allocator>::type allocator_type;
+ typedef __identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -546,7 +560,7 @@ public:
set(set&& __s)
_NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
: __tree_(_VSTD::move(__s.__tree_)) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit set(const allocator_type& __a)
@@ -597,7 +611,7 @@ public:
__tree_ = _VSTD::move(__s.__tree_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~set() {
@@ -652,7 +666,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
pair<iterator,bool> insert(const value_type& __v)
@@ -681,7 +695,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p);}
@@ -795,6 +809,10 @@ public:
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
@@ -852,12 +870,12 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
- class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
class = _EnableIf<__is_allocator<_Allocator>::value, void>,
class = _EnableIf<!__is_allocator<_Compare>::value, void>>
set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
- -> set<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>;
+ -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
template<class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key>,
@@ -869,8 +887,8 @@ set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
template<class _InputIterator, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
set(_InputIterator, _InputIterator, _Allocator)
- -> set<typename iterator_traits<_InputIterator>::value_type,
- less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>;
+ -> set<__iter_value_type<_InputIterator>,
+ less<__iter_value_type<_InputIterator>>, _Allocator>;
template<class _Key, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
@@ -892,7 +910,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Compare, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -964,7 +982,7 @@ template <class _Key, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
typename set<_Key, _Compare, _Allocator>::size_type
erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -974,11 +992,11 @@ class _LIBCPP_TEMPLATE_VIS multiset
{
public:
// types:
- typedef _Key key_type;
+ typedef _Key key_type;
typedef key_type value_type;
- typedef _Compare key_compare;
+ typedef _Compare key_compare;
typedef key_compare value_compare;
- typedef typename __identity<_Allocator>::type allocator_type;
+ typedef __identity_t<_Allocator> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -1077,7 +1095,7 @@ public:
: __tree_(_VSTD::move(__s.__tree_)) {}
multiset(multiset&& __s, const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit multiset(const allocator_type& __a)
: __tree_(__a) {}
@@ -1124,7 +1142,7 @@ public:
__tree_ = _VSTD::move(__s.__tree_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~multiset() {
@@ -1179,7 +1197,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const value_type& __v)
@@ -1208,7 +1226,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p);}
@@ -1301,11 +1319,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
find(const _K2& __k) {return __tree_.find(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
find(const _K2& __k) const {return __tree_.find(__k);}
#endif
@@ -1322,6 +1340,10 @@ public:
#if _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
bool contains(const key_type& __k) const {return find(__k) != end();}
+ template <typename _K2>
+ _LIBCPP_INLINE_VISIBILITY
+ typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+ contains(const _K2& __k) const { return find(__k) != end(); }
#endif // _LIBCPP_STD_VER > 17
_LIBCPP_INLINE_VISIBILITY
@@ -1333,12 +1355,12 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
#endif
@@ -1351,11 +1373,11 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
#endif
@@ -1368,23 +1390,23 @@ public:
#if _LIBCPP_STD_VER > 11
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);}
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
- typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+ typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
#endif
};
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
- class _Allocator = allocator<typename iterator_traits<_InputIterator>::value_type>,
+ class _Compare = less<__iter_value_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_value_type<_InputIterator>>,
class = _EnableIf<__is_allocator<_Allocator>::value, void>,
class = _EnableIf<!__is_allocator<_Compare>::value, void>>
multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
- -> multiset<typename iterator_traits<_InputIterator>::value_type, _Compare, _Allocator>;
+ -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>;
template<class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key>,
@@ -1396,8 +1418,8 @@ multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator(
template<class _InputIterator, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
multiset(_InputIterator, _InputIterator, _Allocator)
- -> multiset<typename iterator_traits<_InputIterator>::value_type,
- less<typename iterator_traits<_InputIterator>::value_type>, _Allocator>;
+ -> multiset<__iter_value_type<_InputIterator>,
+ less<__iter_value_type<_InputIterator>>, _Allocator>;
template<class _Key, class _Allocator,
class = _EnableIf<__is_allocator<_Allocator>::value, void>>
@@ -1419,7 +1441,7 @@ multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_t
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Compare, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1490,10 +1512,10 @@ template <class _Key, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
typename multiset<_Key, _Compare, _Allocator>::size_type
erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_SET
+#endif // _LIBCPP_SET
diff --git a/contrib/llvm-project/libcxx/include/setjmp.h b/contrib/llvm-project/libcxx/include/setjmp.h
index f30a8d401d1a..f9fb2ffe00b2 100644
--- a/contrib/llvm-project/libcxx/include/setjmp.h
+++ b/contrib/llvm-project/libcxx/include/setjmp.h
@@ -41,4 +41,4 @@ void longjmp(jmp_buf env, int val);
#endif // __cplusplus
-#endif // _LIBCPP_SETJMP_H
+#endif // _LIBCPP_SETJMP_H
diff --git a/contrib/llvm-project/libcxx/include/shared_mutex b/contrib/llvm-project/libcxx/include/shared_mutex
index 5448d8a80715..8205c3e0af0c 100644
--- a/contrib/llvm-project/libcxx/include/shared_mutex
+++ b/contrib/llvm-project/libcxx/include/shared_mutex
@@ -122,8 +122,8 @@ template <class Mutex>
*/
-#include <__config>
#include <__availability>
+#include <__config>
#include <version>
_LIBCPP_PUSH_MACROS
@@ -500,10 +500,10 @@ swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT
_LIBCPP_END_NAMESPACE_STD
-#endif // !_LIBCPP_HAS_NO_THREADS
+#endif // !_LIBCPP_HAS_NO_THREADS
-#endif // _LIBCPP_STD_VER > 11
+#endif // _LIBCPP_STD_VER > 11
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_SHARED_MUTEX
+#endif // _LIBCPP_SHARED_MUTEX
diff --git a/contrib/llvm-project/libcxx/include/span b/contrib/llvm-project/libcxx/include/span
index 4f63d0ac4e1f..260a74404fe5 100644
--- a/contrib/llvm-project/libcxx/include/span
+++ b/contrib/llvm-project/libcxx/include/span
@@ -22,6 +22,12 @@ inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
template <class ElementType, size_t Extent = dynamic_extent>
class span;
+template<class ElementType, size_t Extent>
+ inline constexpr bool ranges::enable_view<span<ElementType, Extent>> = true;
+
+template<class ElementType, size_t Extent>
+ inline constexpr bool ranges::enable_borrowed_range<span<ElementType, Extent>> = true;
+
// [span.objectrep], views of object representation
template <class ElementType, size_t Extent>
span<const byte, ((Extent == dynamic_extent) ? dynamic_extent :
@@ -32,7 +38,6 @@ template <class ElementType, size_t Extent>
(sizeof(ElementType) * Extent))> as_writable_bytes(span<ElementType, Extent> s) noexcept;
-namespace std {
template <class ElementType, size_t Extent = dynamic_extent>
class span {
public:
@@ -123,10 +128,16 @@ template<class Container>
*/
#include <__config>
+#include <__debug>
+#include <__iterator/wrap_iter.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
#include <array> // for array
#include <cstddef> // for byte
#include <iterator> // for iterators
+#include <limits>
#include <type_traits> // for remove_cv, etc
+#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -197,7 +208,11 @@ public:
using const_pointer = const _Tp *;
using reference = _Tp &;
using const_reference = const _Tp &;
- using iterator = __wrap_iter<pointer>;
+#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
+ using iterator = pointer;
+#else
+ using iterator = __wrap_iter<pointer>;
+#endif
using reverse_iterator = _VSTD::reverse_iterator<iterator>;
static constexpr size_type extent = _Extent;
@@ -372,7 +387,11 @@ public:
using const_pointer = const _Tp *;
using reference = _Tp &;
using const_reference = const _Tp &;
- using iterator = __wrap_iter<pointer>;
+#if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS)
+ using iterator = pointer;
+#else
+ using iterator = __wrap_iter<pointer>;
+#endif
using reverse_iterator = _VSTD::reverse_iterator<iterator>;
static constexpr size_type extent = dynamic_extent;
@@ -516,6 +535,14 @@ private:
size_type __size;
};
+#if !defined(_LIBCPP_HAS_NO_RANGES)
+template <class _Tp, size_t _Extent>
+inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true;
+
+template <class _ElementType, size_t _Extent>
+inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
+#endif // !defined(_LIBCPP_HAS_NO_RANGES)
+
// as_bytes & as_writable_bytes
template <class _Tp, size_t _Extent>
_LIBCPP_INLINE_VISIBILITY
diff --git a/contrib/llvm-project/libcxx/include/sstream b/contrib/llvm-project/libcxx/include/sstream
index 7ce85be6ac32..fbe5ffcab4c6 100644
--- a/contrib/llvm-project/libcxx/include/sstream
+++ b/contrib/llvm-project/libcxx/include/sstream
@@ -181,8 +181,8 @@ typedef basic_stringstream<wchar_t> wstringstream;
*/
#include <__config>
-#include <ostream>
#include <istream>
+#include <ostream>
#include <string>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -219,19 +219,13 @@ private:
public:
// 30.8.2.1 [stringbuf.cons], constructors
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {}
+ basic_stringbuf()
+ : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}
_LIBCPP_INLINE_VISIBILITY
explicit basic_stringbuf(ios_base::openmode __wch)
: __hm_(nullptr), __mode_(__wch) {}
-#else
- _LIBCPP_INLINE_VISIBILITY
- explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in |
- ios_base::out)
- : __hm_(nullptr), __mode_(__wch) {}
-#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_stringbuf(const string_type& __s,
@@ -542,7 +536,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
ptrdiff_t __nout = this->pptr() - this->pbase();
ptrdiff_t __hm = __hm_ - this->pbase();
__str_.push_back(char_type());
@@ -557,7 +551,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
{
return traits_type::eof();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
__hm_ = _VSTD::max(this->pptr() + 1, __hm_);
if (__mode_ & ios_base::in)
@@ -643,18 +637,13 @@ private:
public:
// 30.8.3.1 [istringstream.cons], constructors
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- basic_istringstream() : basic_istringstream(ios_base::in) {}
+ basic_istringstream()
+ : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}
_LIBCPP_INLINE_VISIBILITY
explicit basic_istringstream(ios_base::openmode __wch)
: basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}
-#else
- _LIBCPP_INLINE_VISIBILITY
- explicit basic_istringstream(ios_base::openmode __wch = ios_base::in)
- : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {}
-#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_istringstream(const string_type& __s,
@@ -728,20 +717,13 @@ private:
public:
// 30.8.4.1 [ostringstream.cons], constructors
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- basic_ostringstream() : basic_ostringstream(ios_base::out) {}
+ basic_ostringstream()
+ : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}
_LIBCPP_INLINE_VISIBILITY
explicit basic_ostringstream(ios_base::openmode __wch)
- : basic_ostream<_CharT, _Traits>(&__sb_),
- __sb_(__wch | ios_base::out) {}
-#else
- _LIBCPP_INLINE_VISIBILITY
- explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out)
- : basic_ostream<_CharT, _Traits>(&__sb_),
- __sb_(__wch | ios_base::out) {}
-#endif
+ : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) {}
_LIBCPP_INLINE_VISIBILITY
explicit basic_ostringstream(const string_type& __s,
@@ -816,19 +798,13 @@ private:
public:
// 30.8.5.1 [stringstream.cons], constructors
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- basic_stringstream() : basic_stringstream(ios_base::in | ios_base::out) {}
+ basic_stringstream()
+ : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}
_LIBCPP_INLINE_VISIBILITY
explicit basic_stringstream(ios_base::openmode __wch)
: basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}
-#else
- _LIBCPP_INLINE_VISIBILITY
- explicit basic_stringstream(ios_base::openmode __wch = ios_base::in |
- ios_base::out)
- : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {}
-#endif
_LIBCPP_INLINE_VISIBILITY
explicit basic_stringstream(const string_type& __s,
@@ -892,4 +868,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_SSTREAM
+#endif // _LIBCPP_SSTREAM
diff --git a/contrib/llvm-project/libcxx/include/stack b/contrib/llvm-project/libcxx/include/stack
index 2a2b350386e5..aefef31ac97b 100644
--- a/contrib/llvm-project/libcxx/include/stack
+++ b/contrib/llvm-project/libcxx/include/stack
@@ -88,6 +88,8 @@ template <class T, class Container>
*/
#include <__config>
+#include <__memory/uses_allocator.h>
+#include <__utility/forward.h>
#include <deque>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -148,7 +150,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
explicit stack(const container_type& __c) : c(__c) {}
@@ -156,35 +158,30 @@ public:
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit stack(const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(__a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
stack(const container_type& __c, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(__c, __a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
stack(const stack& __s, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(__s.c, __a) {}
#ifndef _LIBCPP_CXX03_LANG
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
stack(container_type&& __c, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(_VSTD::move(__c), __a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
stack(stack&& __s, const _Alloc& __a,
- typename enable_if<uses_allocator<container_type,
- _Alloc>::value>::type* = 0)
+ _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
: c(_VSTD::move(__s.c), __a) {}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
@@ -210,7 +207,7 @@ public:
void emplace(_Args&&... __args)
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);}
#endif
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void pop() {c.pop_back();}
@@ -236,15 +233,15 @@ public:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _Container,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
+ class = _EnableIf<!__is_allocator<_Container>::value>
>
stack(_Container)
-> stack<typename _Container::value_type, _Container>;
template<class _Container,
class _Alloc,
- class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
- class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
+ class = _EnableIf<!__is_allocator<_Container>::value>,
+ class = _EnableIf<uses_allocator<_Container, _Alloc>::value>
>
stack(_Container, _Alloc)
-> stack<typename _Container::value_type, _Container>;
@@ -300,10 +297,7 @@ operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
template <class _Tp, class _Container>
inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if<
- __is_swappable<_Container>::value,
- void
->::type
+_EnableIf<__is_swappable<_Container>::value, void>
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
@@ -318,4 +312,4 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STACK
+#endif // _LIBCPP_STACK
diff --git a/contrib/llvm-project/libcxx/include/stdbool.h b/contrib/llvm-project/libcxx/include/stdbool.h
index 81a7cb3038b8..69f7719f26cd 100644
--- a/contrib/llvm-project/libcxx/include/stdbool.h
+++ b/contrib/llvm-project/libcxx/include/stdbool.h
@@ -35,4 +35,4 @@ Macros:
#define __bool_true_false_are_defined 1
#endif
-#endif // _LIBCPP_STDBOOL_H
+#endif // _LIBCPP_STDBOOL_H
diff --git a/contrib/llvm-project/libcxx/include/stddef.h b/contrib/llvm-project/libcxx/include/stddef.h
index 35c680b4f9a9..2f8c0a5f5bf2 100644
--- a/contrib/llvm-project/libcxx/include/stddef.h
+++ b/contrib/llvm-project/libcxx/include/stddef.h
@@ -53,4 +53,4 @@ using std::nullptr_t;
#endif
-#endif // _LIBCPP_STDDEF_H
+#endif // _LIBCPP_STDDEF_H
diff --git a/contrib/llvm-project/libcxx/include/stdexcept b/contrib/llvm-project/libcxx/include/stdexcept
index 7b5de7ea367c..c0470d1e1dd3 100644
--- a/contrib/llvm-project/libcxx/include/stdexcept
+++ b/contrib/llvm-project/libcxx/include/stdexcept
@@ -42,9 +42,9 @@ public:
*/
#include <__config>
-#include <cstdlib>
#include <exception>
#include <iosfwd> // for string forward decl
+#include <cstdlib>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -306,4 +306,4 @@ void __throw_underflow_error(const char*__msg)
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STDEXCEPT
+#endif // _LIBCPP_STDEXCEPT
diff --git a/contrib/llvm-project/libcxx/include/stdint.h b/contrib/llvm-project/libcxx/include/stdint.h
index d7b6902518ae..5d64910bfe55 100644
--- a/contrib/llvm-project/libcxx/include/stdint.h
+++ b/contrib/llvm-project/libcxx/include/stdint.h
@@ -122,4 +122,4 @@ Macros:
#include_next <stdint.h>
-#endif // _LIBCPP_STDINT_H
+#endif // _LIBCPP_STDINT_H
diff --git a/contrib/llvm-project/libcxx/include/stdio.h b/contrib/llvm-project/libcxx/include/stdio.h
index e08e6bc9b698..f84122034891 100644
--- a/contrib/llvm-project/libcxx/include/stdio.h
+++ b/contrib/llvm-project/libcxx/include/stdio.h
@@ -116,4 +116,4 @@ void perror(const char* s);
#endif
-#endif // _LIBCPP_STDIO_H
+#endif // _LIBCPP_STDIO_H
diff --git a/contrib/llvm-project/libcxx/include/stdlib.h b/contrib/llvm-project/libcxx/include/stdlib.h
index 812ea1024edf..242eedc22a5b 100644
--- a/contrib/llvm-project/libcxx/include/stdlib.h
+++ b/contrib/llvm-project/libcxx/include/stdlib.h
@@ -103,7 +103,7 @@ extern "C++" {
#endif
// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
return __builtin_labs(__x);
}
@@ -112,9 +112,9 @@ inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
return __builtin_llabs(__x);
}
#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
-#if !(defined(_AIX) || defined(__sun__))
+#if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
}
@@ -127,7 +127,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double
abs(long double __lcpp_x) _NOEXCEPT {
return __builtin_fabsl(__lcpp_x);
}
-#endif // !(defined(_AIX) || defined(__sun__))
+#endif // !defined(__sun__)
// div
@@ -138,7 +138,7 @@ abs(long double __lcpp_x) _NOEXCEPT {
#endif
// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
return ::ldiv(__x, __y);
}
@@ -148,8 +148,8 @@ inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
return ::lldiv(__x, __y);
}
#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
+#endif // _LIBCPP_MSVCRT / __sun__
} // extern "C++"
-#endif // __cplusplus
+#endif // __cplusplus
-#endif // _LIBCPP_STDLIB_H
+#endif // _LIBCPP_STDLIB_H
diff --git a/contrib/llvm-project/libcxx/include/streambuf b/contrib/llvm-project/libcxx/include/streambuf
index 0dfa31449b90..385d48694580 100644
--- a/contrib/llvm-project/libcxx/include/streambuf
+++ b/contrib/llvm-project/libcxx/include/streambuf
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_STEAMBUF
-#define _LIBCPP_STEAMBUF
+#ifndef _LIBCPP_STREAMBUF
+#define _LIBCPP_STREAMBUF
/*
streambuf synopsis
@@ -108,8 +108,8 @@ protected:
*/
#include <__config>
-#include <iosfwd>
#include <ios>
+#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -495,4 +495,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_STEAMBUF
+#endif // _LIBCPP_STREAMBUF
diff --git a/contrib/llvm-project/libcxx/include/string b/contrib/llvm-project/libcxx/include/string
index 687795c79bb9..4940021b0c68 100644
--- a/contrib/llvm-project/libcxx/include/string
+++ b/contrib/llvm-project/libcxx/include/string
@@ -69,6 +69,9 @@ struct char_traits
template <> struct char_traits<char>;
template <> struct char_traits<wchar_t>;
+template <> struct char_traits<char8_t>; // C++20
+template <> struct char_traits<char16_t>;
+template <> struct char_traits<char32_t>;
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_string
@@ -107,6 +110,7 @@ public:
explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17
basic_string(const value_type* s, const allocator_type& a = allocator_type());
basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());
+ basic_string(nullptr_t) = delete; // C++2b
basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());
template<class InputIterator>
basic_string(InputIterator begin, InputIterator end,
@@ -127,6 +131,7 @@ public:
allocator_type::propagate_on_container_move_assignment::value ||
allocator_type::is_always_equal::value ); // C++17
basic_string& operator=(const value_type* s);
+ basic_string& operator=(nullptr_t) = delete; // C++2b
basic_string& operator=(value_type c);
basic_string& operator=(initializer_list<value_type>);
@@ -262,49 +267,49 @@ public:
size_type find(const basic_string& str, size_type pos = 0) const noexcept;
template <class T>
- size_type find(const T& t, size_type pos = 0) const; // C++17
+ size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension
size_type find(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find(const value_type* s, size_type pos = 0) const noexcept;
size_type find(value_type c, size_type pos = 0) const noexcept;
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
template <class T>
- size_type rfind(const T& t, size_type pos = npos) const; // C++17
+ size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension
size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
size_type rfind(value_type c, size_type pos = npos) const noexcept;
size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
template <class T>
- size_type find_first_of(const T& t, size_type pos = 0) const; // C++17
+ size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension
size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;
size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
template <class T>
- size_type find_last_of(const T& t, size_type pos = npos) const noexcept; // C++17
+ size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension
size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
template <class T>
- size_type find_first_not_of(const T& t, size_type pos = 0) const; // C++17
+ size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension
size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;
size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
template <class T>
- size_type find_last_not_of(const T& t, size_type pos = npos) const; // C++17
+ size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension
size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
int compare(const basic_string& str) const noexcept;
template <class T>
- int compare(const T& t) const noexcept; // C++17
+ int compare(const T& t) const noexcept; // C++17, noexcept as an extension
int compare(size_type pos1, size_type n1, const basic_string& str) const;
template <class T>
int compare(size_type pos1, size_type n1, const T& t) const; // C++17
@@ -450,6 +455,7 @@ erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
+typedef basic_string<char8_t> u8string; // C++20
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
@@ -494,12 +500,14 @@ wstring to_wstring(double val);
wstring to_wstring(long double val);
template <> struct hash<string>;
+template <> struct hash<u8string>; // C++20
template <> struct hash<u16string>;
template <> struct hash<u32string>;
template <> struct hash<wstring>;
basic_string<char> operator "" s( const char *str, size_t len ); // C++14
basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14
+basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20
basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14
basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14
@@ -508,26 +516,28 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
*/
#include <__config>
-#include <string_view>
-#include <iosfwd>
+#include <__debug>
+#include <__functional_base>
+#include <__iterator/wrap_iter.h>
+#include <algorithm>
+#include <compare>
+#include <cstdio> // EOF
#include <cstring>
-#include <cstdio> // For EOF.
#include <cwchar>
-#include <algorithm>
+#include <initializer_list>
+#include <iosfwd>
#include <iterator>
-#include <utility>
#include <memory>
#include <stdexcept>
+#include <string_view>
#include <type_traits>
-#include <initializer_list>
-#include <__functional_base>
+#include <utility>
#include <version>
+
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-#include <cstdint>
+# include <cstdint>
#endif
-#include <__debug>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -625,29 +635,16 @@ __basic_string_common<__b>::__throw_out_of_range() const
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>)
-#ifdef _LIBCPP_NO_EXCEPTIONS
-template <class _Iter>
-struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {};
-#elif defined(_LIBCPP_HAS_NO_NOEXCEPT)
template <class _Iter>
-struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {};
-#else
-template <class _Iter, bool = __is_cpp17_forward_iterator<_Iter>::value>
-struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT((
- noexcept(++(declval<_Iter&>())) &&
- is_nothrow_assignable<_Iter&, _Iter>::value &&
- noexcept(declval<_Iter>() == declval<_Iter>()) &&
- noexcept(*declval<_Iter>())
-)) {};
-
-template <class _Iter>
-struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {};
-#endif
+struct __string_is_trivial_iterator : public false_type {};
+template <class _Tp>
+struct __string_is_trivial_iterator<_Tp*>
+ : public is_arithmetic<_Tp> {};
template <class _Iter>
-struct __libcpp_string_gets_noexcept_iterator
- : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {};
+struct __string_is_trivial_iterator<__wrap_iter<_Iter> >
+ : public __string_is_trivial_iterator<_Iter> {};
template <class _CharT, class _Traits, class _Tp>
struct __can_be_converted_to_string_view : public _BoolConstant<
@@ -668,21 +665,21 @@ struct __padding<_CharT, 1>
{
};
-#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef basic_string<char8_t> u8string;
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
+#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
template<class _CharT, class _Traits, class _Allocator>
class
_LIBCPP_TEMPLATE_VIS
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
_LIBCPP_PREFERRED_NAME(u8string)
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
@@ -736,7 +733,7 @@ private:
#else // _LIBCPP_BIG_ENDIAN
static const size_type __short_mask = 0x80;
static const size_type __long_mask = ~(size_type(~0) >> 1);
-#endif // _LIBCPP_BIG_ENDIAN
+#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
(sizeof(__long) - 1)/sizeof(value_type) : 2};
@@ -766,7 +763,7 @@ private:
#else // _LIBCPP_BIG_ENDIAN
static const size_type __short_mask = 0x01;
static const size_type __long_mask = 0x1ul;
-#endif // _LIBCPP_BIG_ENDIAN
+#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
(sizeof(__long) - 1)/sizeof(value_type) : 2};
@@ -781,7 +778,7 @@ private:
value_type __data_[__min_cap];
};
-#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
union __ulx{__long __lx; __short __lxx;};
@@ -805,7 +802,7 @@ private:
__compressed_pair<__rep, allocator_type> __r_;
public:
- _LIBCPP_FUNC_VIS
+ _LIBCPP_TEMPLATE_DATA_VIS
static const size_type npos = -1;
_LIBCPP_INLINE_VISIBILITY basic_string()
@@ -832,7 +829,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_string(basic_string&& __str, const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> >
_LIBCPP_INLINE_VISIBILITY
@@ -848,6 +845,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_string(const _CharT* __s, const _Allocator& __a);
+#if _LIBCPP_STD_VER > 20
+ basic_string(nullptr_t) = delete;
+#endif
+
_LIBCPP_INLINE_VISIBILITY
basic_string(const _CharT* __s, size_type __n);
_LIBCPP_INLINE_VISIBILITY
@@ -890,7 +891,7 @@ public:
basic_string(initializer_list<_CharT> __il);
_LIBCPP_INLINE_VISIBILITY
basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
inline ~basic_string();
@@ -911,6 +912,9 @@ public:
basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
#endif
_LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
+#if _LIBCPP_STD_VER > 20
+ basic_string& operator=(nullptr_t) = delete;
+#endif
basic_string& operator=(value_type __c);
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -939,7 +943,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_iterator end() const _NOEXCEPT
{return const_iterator(__get_pointer() + size());}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
_LIBCPP_INLINE_VISIBILITY
reverse_iterator rbegin() _NOEXCEPT
{return reverse_iterator(end());}
@@ -1010,7 +1014,7 @@ public:
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_string& append(const basic_string& __str);
@@ -1041,20 +1045,16 @@ public:
_LIBCPP_INLINE_VISIBILITY
void __append_default_init(size_type __n);
- template <class _ForwardIterator>
- _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
- basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator);
template<class _InputIterator>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
_EnableIf
<
- __is_exactly_cpp17_input_iterator<_InputIterator>::value
- || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
basic_string&
>
_LIBCPP_INLINE_VISIBILITY
append(_InputIterator __first, _InputIterator __last) {
- const basic_string __temp (__first, __last, __alloc());
+ const basic_string __temp(__first, __last, __alloc());
append(__temp.data(), __temp.size());
return *this;
}
@@ -1062,19 +1062,16 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
_EnableIf
<
- __is_cpp17_forward_iterator<_ForwardIterator>::value
- && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
basic_string&
>
_LIBCPP_INLINE_VISIBILITY
- append(_ForwardIterator __first, _ForwardIterator __last) {
- return __append_forward_unsafe(__first, __last);
- }
+ append(_ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
void push_back(value_type __c);
_LIBCPP_INLINE_VISIBILITY
@@ -1117,8 +1114,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
_EnableIf
<
- __is_exactly_cpp17_input_iterator<_InputIterator>::value
- || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
basic_string&
>
assign(_InputIterator __first, _InputIterator __last);
@@ -1126,15 +1122,14 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
_EnableIf
<
- __is_cpp17_forward_iterator<_ForwardIterator>::value
- && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
basic_string&
>
assign(_ForwardIterator __first, _ForwardIterator __last);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
basic_string& insert(size_type __pos1, const basic_string& __str);
@@ -1168,8 +1163,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
_EnableIf
<
- __is_exactly_cpp17_input_iterator<_InputIterator>::value
- || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
iterator
>
insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
@@ -1177,8 +1171,7 @@ public:
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
_EnableIf
<
- __is_cpp17_forward_iterator<_ForwardIterator>::value
- && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
iterator
>
insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
@@ -1186,7 +1179,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator __pos, initializer_list<value_type> __il)
{return insert(__pos, __il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
basic_string& erase(size_type __pos = 0, size_type __n = npos);
_LIBCPP_INLINE_VISIBILITY
@@ -1247,7 +1240,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
{return replace(__i1, __i2, __il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
_LIBCPP_INLINE_VISIBILITY
@@ -1284,7 +1277,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
- find(const _Tp& __t, size_type __pos = 0) const;
+ find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
@@ -1300,7 +1293,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
- rfind(const _Tp& __t, size_type __pos = npos) const;
+ rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
@@ -1316,7 +1309,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
- find_first_of(const _Tp& __t, size_type __pos = 0) const;
+ find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
@@ -1333,7 +1326,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
- find_last_of(const _Tp& __t, size_type __pos = npos) const;
+ find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
@@ -1350,7 +1343,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
- find_first_not_of(const _Tp &__t, size_type __pos = 0) const;
+ find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;
size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
@@ -1367,7 +1360,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
size_type
>
- find_last_not_of(const _Tp& __t, size_type __pos = npos) const;
+ find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
@@ -1384,7 +1377,7 @@ public:
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
int
>
- compare(const _Tp &__t) const;
+ compare(const _Tp &__t) const _NOEXCEPT;
template <class _Tp>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
@@ -1468,7 +1461,7 @@ public:
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
_LIBCPP_INLINE_VISIBILITY
@@ -1514,7 +1507,7 @@ private:
{return __r_.first().__s.__size_ >> 1;}
# endif
-#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
_LIBCPP_INLINE_VISIBILITY
void __set_long_size(size_type __s) _NOEXCEPT
@@ -1714,6 +1707,13 @@ private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
+ template<class _Tp>
+ _LIBCPP_INLINE_VISIBILITY
+ bool __addr_in_range(_Tp&& __t) const {
+ const volatile void *__p = _VSTD::addressof(__t);
+ return data() <= __p && __p <= data() + size();
+ }
+
friend basic_string operator+<>(const basic_string&, const basic_string&);
friend basic_string operator+<>(const value_type*, const basic_string&);
friend basic_string operator+<>(value_type, const basic_string&);
@@ -1734,7 +1734,7 @@ _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _CharT = typename iterator_traits<_InputIterator>::value_type,
+ class _CharT = __iter_value_type<_InputIterator>,
class _Allocator = allocator<_CharT>,
class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>,
class = _EnableIf<__is_allocator<_Allocator>::value>
@@ -1773,11 +1773,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
template <class _CharT, class _Traits, class _Allocator>
inline
void
-basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
-#if _LIBCPP_DEBUG_LEVEL == 2
- __pos
-#endif
- )
+basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
{
#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
@@ -1797,7 +1793,9 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
}
__get_db()->unlock();
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#else
+ (void)__pos;
+#endif // _LIBCPP_DEBUG_LEVEL == 2
}
template <class _CharT, class _Traits, class _Allocator>
@@ -2001,7 +1999,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co
#endif
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
void
@@ -2129,7 +2127,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __first != __last; ++__first)
push_back(*__first);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2140,7 +2138,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
__alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _CharT, class _Traits, class _Allocator>
@@ -2168,9 +2166,23 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
__set_long_cap(__cap+1);
__set_long_size(__sz);
}
+
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __first != __last; ++__first, (void) ++__p)
traits_type::assign(*__p, *__first);
traits_type::assign(*__p, value_type());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ if (__is_long())
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
+ throw;
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _CharT, class _Traits, class _Allocator>
@@ -2225,7 +2237,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
#endif
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>::~basic_string()
@@ -2357,12 +2369,11 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
size_type __sz = size();
__grow_by(__cap, __n - __cap, __sz, 0, __sz);
}
- else
- __invalidate_iterators_past(__n);
value_type* __p = _VSTD::__to_address(__get_pointer());
traits_type::assign(__p, __n, __c);
traits_type::assign(__p[__n], value_type());
__set_size(__n);
+ __invalidate_iterators_past(__n);
return *this;
}
@@ -2463,8 +2474,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
_EnableIf
<
- __is_exactly_cpp17_input_iterator <_InputIterator>::value
- || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
basic_string<_CharT, _Traits, _Allocator>&
>
basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -2478,26 +2488,35 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
_EnableIf
<
- __is_cpp17_forward_iterator<_ForwardIterator>::value
- && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
basic_string<_CharT, _Traits, _Allocator>&
>
basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
- size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
size_type __cap = capacity();
- if (__cap < __n)
+ size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ?
+ static_cast<size_type>(_VSTD::distance(__first, __last)) : 0;
+
+ if (__string_is_trivial_iterator<_ForwardIterator>::value &&
+ (__cap >= __n || !__addr_in_range(*__first)))
{
- size_type __sz = size();
- __grow_by(__cap, __n - __cap, __sz, 0, __sz);
+ if (__cap < __n)
+ {
+ size_type __sz = size();
+ __grow_by(__cap, __n - __cap, __sz, 0, __sz);
+ }
+ pointer __p = __get_pointer();
+ for (; __first != __last; ++__first, ++__p)
+ traits_type::assign(*__p, *__first);
+ traits_type::assign(*__p, value_type());
+ __set_size(__n);
+ __invalidate_iterators_past(__n);
}
else
- __invalidate_iterators_past(__n);
- pointer __p = __get_pointer();
- for (; __first != __last; ++__first, ++__p)
- traits_type::assign(*__p, *__first);
- traits_type::assign(*__p, value_type());
- __set_size(__n);
+ {
+ const basic_string __temp(__first, __last, __alloc());
+ assign(__temp.data(), __temp.size());
+ }
return *this;
}
@@ -2644,39 +2663,23 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
traits_type::assign(*++__p, value_type());
}
-template <class _Tp>
-bool __ptr_in_range (const _Tp* __p, const _Tp* __first, const _Tp* __last)
-{
- return __first <= __p && __p < __last;
-}
-
-template <class _Tp1, class _Tp2>
-bool __ptr_in_range (const _Tp1*, const _Tp2*, const _Tp2*)
-{
- return false;
-}
-
template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
-basic_string<_CharT, _Traits, _Allocator>&
-basic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe(
+_EnableIf
+<
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
+ basic_string<_CharT, _Traits, _Allocator>&
+>
+basic_string<_CharT, _Traits, _Allocator>::append(
_ForwardIterator __first, _ForwardIterator __last)
{
- static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "function requires a ForwardIterator");
size_type __sz = size();
size_type __cap = capacity();
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n)
{
- typedef typename iterator_traits<_ForwardIterator>::reference _CharRef;
- _CharRef __tmp_ref = *__first;
- if (__ptr_in_range(_VSTD::addressof(__tmp_ref), data(), data() + size()))
- {
- const basic_string __temp (__first, __last, __alloc());
- append(__temp.data(), __temp.size());
- }
- else
+ if (__string_is_trivial_iterator<_ForwardIterator>::value &&
+ !__addr_in_range(*__first))
{
if (__cap - __sz < __n)
__grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
@@ -2686,6 +2689,11 @@ basic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe(
traits_type::assign(*__p, value_type());
__set_size(__sz + __n);
}
+ else
+ {
+ const basic_string __temp(__first, __last, __alloc());
+ append(__temp.data(), __temp.size());
+ }
}
return *this;
}
@@ -2801,8 +2809,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _InputIterator>
_EnableIf
<
- __is_exactly_cpp17_input_iterator<_InputIterator>::value
- || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
+ __is_exactly_cpp17_input_iterator<_InputIterator>::value,
typename basic_string<_CharT, _Traits, _Allocator>::iterator
>
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
@@ -2820,8 +2827,7 @@ template <class _CharT, class _Traits, class _Allocator>
template<class _ForwardIterator>
_EnableIf
<
- __is_cpp17_forward_iterator<_ForwardIterator>::value
- && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,
+ __is_cpp17_forward_iterator<_ForwardIterator>::value,
typename basic_string<_CharT, _Traits, _Allocator>::iterator
>
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
@@ -2835,34 +2841,35 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward
size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__n)
{
- typedef typename iterator_traits<_ForwardIterator>::reference _CharRef;
- _CharRef __tmp_char = *__first;
- if (__ptr_in_range(_VSTD::addressof(__tmp_char), data(), data() + size()))
+ if (__string_is_trivial_iterator<_ForwardIterator>::value &&
+ !__addr_in_range(*__first))
{
- const basic_string __temp(__first, __last, __alloc());
- return insert(__pos, __temp.data(), __temp.data() + __temp.size());
- }
-
- size_type __sz = size();
- size_type __cap = capacity();
- value_type* __p;
- if (__cap - __sz >= __n)
- {
- __p = _VSTD::__to_address(__get_pointer());
- size_type __n_move = __sz - __ip;
- if (__n_move != 0)
- traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
+ size_type __sz = size();
+ size_type __cap = capacity();
+ value_type* __p;
+ if (__cap - __sz >= __n)
+ {
+ __p = _VSTD::__to_address(__get_pointer());
+ size_type __n_move = __sz - __ip;
+ if (__n_move != 0)
+ traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
+ }
+ else
+ {
+ __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
+ __p = _VSTD::__to_address(__get_long_pointer());
+ }
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ for (__p += __ip; __first != __last; ++__p, ++__first)
+ traits_type::assign(*__p, *__first);
}
else
{
- __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
- __p = _VSTD::__to_address(__get_long_pointer());
+ const basic_string __temp(__first, __last, __alloc());
+ return insert(__pos, __temp.data(), __temp.data() + __temp.size());
}
- __sz += __n;
- __set_size(__sz);
- traits_type::assign(__p[__sz], value_type());
- for (__p += __ip; __first != __last; ++__p, ++__first)
- traits_type::assign(*__p, *__first);
}
return begin() + __ip;
}
@@ -3353,7 +3360,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
- #endif // _LIBCPP_NO_EXCEPTIONS
+ #endif // _LIBCPP_NO_EXCEPTIONS
__new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
@@ -3364,7 +3371,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
#else // _LIBCPP_NO_EXCEPTIONS
if (__new_data == nullptr)
return;
- #endif // _LIBCPP_NO_EXCEPTIONS
+ #endif // _LIBCPP_NO_EXCEPTIONS
}
__now_long = true;
__was_long = __is_long();
@@ -3543,7 +3550,7 @@ _EnableIf
typename basic_string<_CharT, _Traits, _Allocator>::size_type
>
basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
- size_type __pos) const
+ size_type __pos) const _NOEXCEPT
{
__self_view __sv = __t;
return __str_find<value_type, size_type, traits_type, npos>
@@ -3601,7 +3608,7 @@ _EnableIf
typename basic_string<_CharT, _Traits, _Allocator>::size_type
>
basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
- size_type __pos) const
+ size_type __pos) const _NOEXCEPT
{
__self_view __sv = __t;
return __str_rfind<value_type, size_type, traits_type, npos>
@@ -3659,7 +3666,7 @@ _EnableIf
typename basic_string<_CharT, _Traits, _Allocator>::size_type
>
basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
- size_type __pos) const
+ size_type __pos) const _NOEXCEPT
{
__self_view __sv = __t;
return __str_find_first_of<value_type, size_type, traits_type, npos>
@@ -3717,7 +3724,7 @@ _EnableIf
typename basic_string<_CharT, _Traits, _Allocator>::size_type
>
basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
- size_type __pos) const
+ size_type __pos) const _NOEXCEPT
{
__self_view __sv = __t;
return __str_find_last_of<value_type, size_type, traits_type, npos>
@@ -3775,7 +3782,7 @@ _EnableIf
typename basic_string<_CharT, _Traits, _Allocator>::size_type
>
basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
- size_type __pos) const
+ size_type __pos) const _NOEXCEPT
{
__self_view __sv = __t;
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
@@ -3834,7 +3841,7 @@ _EnableIf
typename basic_string<_CharT, _Traits, _Allocator>::size_type
>
basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
- size_type __pos) const
+ size_type __pos) const _NOEXCEPT
{
__self_view __sv = __t;
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
@@ -3871,7 +3878,7 @@ _EnableIf
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
int
>
-basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const
+basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT
{
__self_view __sv = __t;
size_t __lhs_sz = size();
@@ -4349,7 +4356,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
return _VSTD::move(__lhs);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// swap
@@ -4404,7 +4411,7 @@ _LIBCPP_FUNC_VIS wstring to_wstring(double __val);
_LIBCPP_FUNC_VIS wstring to_wstring(long double __val);
template<class _CharT, class _Traits, class _Allocator>
-_LIBCPP_FUNC_VIS
+_LIBCPP_TEMPLATE_DATA_VIS
const typename basic_string<_CharT, _Traits, _Allocator>::size_type
basic_string<_CharT, _Traits, _Allocator>::npos;
@@ -4441,8 +4448,6 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str);
-#ifndef _LIBCPP_CXX03_LANG
-
template<class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
@@ -4455,8 +4460,6 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>&& __is,
basic_string<_CharT, _Traits, _Allocator>& __str);
-#endif // _LIBCPP_CXX03_LANG
-
#if _LIBCPP_STD_VER > 17
template <class _CharT, class _Traits, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
@@ -4513,7 +4516,7 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
return this->data() <= __p && __p < this->data() + this->size();
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
#if _LIBCPP_STD_VER > 11
// Literal suffixes for basic_string [basic.string.literals]
@@ -4533,7 +4536,7 @@ inline namespace literals
return basic_string<wchar_t> (__str, __len);
}
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
inline _LIBCPP_INLINE_VISIBILITY
basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
{
@@ -4560,4 +4563,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_STRING
+#endif // _LIBCPP_STRING
diff --git a/contrib/llvm-project/libcxx/include/string.h b/contrib/llvm-project/libcxx/include/string.h
index e09251d06405..2d563444b7f9 100644
--- a/contrib/llvm-project/libcxx/include/string.h
+++ b/contrib/llvm-project/libcxx/include/string.h
@@ -106,4 +106,4 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
}
#endif
-#endif // _LIBCPP_STRING_H
+#endif // _LIBCPP_STRING_H
diff --git a/contrib/llvm-project/libcxx/include/string_view b/contrib/llvm-project/libcxx/include/string_view
index bc0245cf2b5e..2c94cb85269f 100644
--- a/contrib/llvm-project/libcxx/include/string_view
+++ b/contrib/llvm-project/libcxx/include/string_view
@@ -19,6 +19,12 @@ namespace std {
template<class charT, class traits = char_traits<charT>>
class basic_string_view;
+ template<class charT, class traits>
+ inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
+
+ template<class charT, class traits>
+ inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true; // C++20
+
// 7.9, basic_string_view non-member comparison functions
template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> x,
@@ -48,6 +54,7 @@ namespace std {
// basic_string_view typedef names
typedef basic_string_view<char> string_view;
+ typedef basic_string_view<char8_t> u8string_view; // C++20
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
@@ -76,6 +83,7 @@ namespace std {
basic_string_view& operator=(const basic_string_view&) noexcept = default;
template<class Allocator>
constexpr basic_string_view(const charT* str);
+ basic_string_view(nullptr_t) = delete; // C++2b
constexpr basic_string_view(const charT* str, size_type len);
// 7.4, basic_string_view iterator support
@@ -106,7 +114,7 @@ namespace std {
constexpr void remove_suffix(size_type n);
constexpr void swap(basic_string_view& s) noexcept;
- size_type copy(charT* s, size_type n, size_type pos = 0) const;
+ size_type copy(charT* s, size_type n, size_type pos = 0) const; // constexpr in C++20
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
constexpr int compare(basic_string_view s) const noexcept;
@@ -119,28 +127,28 @@ namespace std {
const charT* s, size_type n2) const;
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
- constexpr size_type find(const charT* s, size_type pos, size_type n) const;
- constexpr size_type find(const charT* s, size_type pos = 0) const;
+ constexpr size_type find(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
+ constexpr size_type find(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
- constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
- constexpr size_type rfind(const charT* s, size_type pos = npos) const;
+ constexpr size_type rfind(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
+ constexpr size_type rfind(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
- constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
- constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
+ constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
+ constexpr size_type find_first_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
- constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
- constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
+ constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
+ constexpr size_type find_last_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
- constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
- constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+ constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
+ constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
- constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
- constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+ constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
+ constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
constexpr bool starts_with(basic_string_view s) const noexcept; // C++20
constexpr bool starts_with(charT c) const noexcept; // C++20
@@ -161,12 +169,14 @@ namespace std {
// 7.11, Hash support
template <class T> struct hash;
template <> struct hash<string_view>;
+ template <> struct hash<u8string_view>; // C++20
template <> struct hash<u16string_view>;
template <> struct hash<u32string_view>;
template <> struct hash<wstring_view>;
constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept;
constexpr basic_string_view<wchar_t> operator "" sv( const wchar_t *str, size_t len ) noexcept;
+ constexpr basic_string_view<char8_t> operator "" sv( const char8_t *str, size_t len ) noexcept; // C++20
constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
@@ -176,14 +186,17 @@ namespace std {
*/
#include <__config>
+#include <__debug>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/enable_view.h>
#include <__string>
-#include <iosfwd>
#include <algorithm>
+#include <compare>
+#include <iosfwd>
#include <iterator>
#include <limits>
#include <stdexcept>
#include <version>
-#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -199,7 +212,7 @@ template<class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS basic_string_view;
typedef basic_string_view<char> string_view;
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
typedef basic_string_view<char8_t> u8string_view;
#endif
typedef basic_string_view<char16_t> u16string_view;
@@ -209,7 +222,7 @@ typedef basic_string_view<wchar_t> wstring_view;
template<class _CharT, class _Traits>
class
_LIBCPP_PREFERRED_NAME(string_view)
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
_LIBCPP_PREFERRED_NAME(u8string_view)
#endif
_LIBCPP_PREFERRED_NAME(u16string_view)
@@ -261,6 +274,10 @@ public:
basic_string_view(const _CharT* __s)
: __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
+#if _LIBCPP_STD_VER > 20
+ basic_string_view(nullptr_t) = delete;
+#endif
+
// [string.view.iterators], iterators
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT { return cbegin(); }
@@ -356,7 +373,7 @@ public:
__other.__size = __sz;
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{
if (__pos > size())
@@ -431,7 +448,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find(const _CharT* __s, size_type __pos, size_type __n) const
+ size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
return __str_find<value_type, size_type, traits_type, npos>
@@ -439,7 +456,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find(const _CharT* __s, size_type __pos = 0) const
+ size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
return __str_find<value_type, size_type, traits_type, npos>
@@ -463,7 +480,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
+ size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
return __str_rfind<value_type, size_type, traits_type, npos>
@@ -471,7 +488,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type rfind(const _CharT* __s, size_type __pos=npos) const
+ size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
return __str_rfind<value_type, size_type, traits_type, npos>
@@ -492,7 +509,7 @@ public:
{ return find(__c, __pos); }
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
+ size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
return __str_find_first_of<value_type, size_type, traits_type, npos>
@@ -500,7 +517,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_first_of(const _CharT* __s, size_type __pos=0) const
+ size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
return __str_find_first_of<value_type, size_type, traits_type, npos>
@@ -521,7 +538,7 @@ public:
{ return rfind(__c, __pos); }
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
+ size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
return __str_find_last_of<value_type, size_type, traits_type, npos>
@@ -529,7 +546,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
+ size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
return __str_find_last_of<value_type, size_type, traits_type, npos>
@@ -553,7 +570,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+ size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
@@ -561,7 +578,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
+ size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
@@ -585,7 +602,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+ size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
{
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
@@ -593,7 +610,7 @@ public:
}
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
+ size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
{
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
@@ -645,6 +662,13 @@ private:
size_type __size;
};
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
+template <class _CharT, class _Traits>
+inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
+
+template <class _CharT, class _Traits>
+inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
// [string.view.comparison]
// operator ==
@@ -842,7 +866,7 @@ inline namespace literals
return basic_string_view<wchar_t> (__str, __len);
}
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
+#ifndef _LIBCPP_HAS_NO_CHAR8_T
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
basic_string_view<char8_t> operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT
{
diff --git a/contrib/llvm-project/libcxx/include/strstream b/contrib/llvm-project/libcxx/include/strstream
index 0062777cd437..ca837aef670f 100644
--- a/contrib/llvm-project/libcxx/include/strstream
+++ b/contrib/llvm-project/libcxx/include/strstream
@@ -130,8 +130,8 @@ private:
*/
#include <__config>
-#include <ostream>
#include <istream>
+#include <ostream>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -163,7 +163,7 @@ public:
strstreambuf(strstreambuf&& __rhs);
_LIBCPP_INLINE_VISIBILITY
strstreambuf& operator=(strstreambuf&& __rhs);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
virtual ~strstreambuf();
@@ -233,7 +233,7 @@ strstreambuf::operator=(strstreambuf&& __rhs)
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
class _LIBCPP_TYPE_VIS istrstream
: public istream
@@ -268,7 +268,7 @@ public:
__sb_ = _VSTD::move(__rhs.__sb_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
virtual ~istrstream();
@@ -317,7 +317,7 @@ public:
__sb_ = _VSTD::move(__rhs.__sb_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
virtual ~ostrstream();
@@ -377,7 +377,7 @@ public:
__sb_ = _VSTD::move(__rhs.__sb_);
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
virtual ~strstream();
@@ -404,4 +404,4 @@ private:
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STRSTREAM
+#endif // _LIBCPP_STRSTREAM
diff --git a/contrib/llvm-project/libcxx/include/system_error b/contrib/llvm-project/libcxx/include/system_error
index b714e1d4263d..aab97681156c 100644
--- a/contrib/llvm-project/libcxx/include/system_error
+++ b/contrib/llvm-project/libcxx/include/system_error
@@ -142,11 +142,14 @@ template <> struct hash<std::error_condition>;
*/
+#include <__config>
#include <__errc>
-#include <type_traits>
-#include <stdexcept>
+#include <__functional/unary_function.h>
#include <__functional_base>
+#include <compare>
+#include <stdexcept>
#include <string>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -289,8 +292,7 @@ public:
string message() const;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT
- operator bool() const _NOEXCEPT {return __val_ != 0;}
+ explicit operator bool() const _NOEXCEPT {return __val_ != 0;}
};
inline _LIBCPP_INLINE_VISIBILITY
@@ -366,8 +368,7 @@ public:
string message() const;
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT
- operator bool() const _NOEXCEPT {return __val_ != 0;}
+ explicit operator bool() const _NOEXCEPT {return __val_ != 0;}
};
inline _LIBCPP_INLINE_VISIBILITY
@@ -484,4 +485,4 @@ void __throw_system_error(int ev, const char* what_arg);
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_SYSTEM_ERROR
+#endif // _LIBCPP_SYSTEM_ERROR
diff --git a/contrib/llvm-project/libcxx/include/tgmath.h b/contrib/llvm-project/libcxx/include/tgmath.h
index 2dc1f771d91c..ba9396e6abb7 100644
--- a/contrib/llvm-project/libcxx/include/tgmath.h
+++ b/contrib/llvm-project/libcxx/include/tgmath.h
@@ -31,6 +31,6 @@
#include_next <tgmath.h>
-#endif // __cplusplus
+#endif // __cplusplus
-#endif // _LIBCPP_TGMATH_H
+#endif // _LIBCPP_TGMATH_H
diff --git a/contrib/llvm-project/libcxx/include/thread b/contrib/llvm-project/libcxx/include/thread
index 34e0c2a23916..acfc20bce2dd 100644
--- a/contrib/llvm-project/libcxx/include/thread
+++ b/contrib/llvm-project/libcxx/include/thread
@@ -83,20 +83,20 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
*/
#include <__config>
-#include <iosfwd>
+#include <__debug>
#include <__functional_base>
-#include <type_traits>
+#include <__mutex_base>
+#include <__threading_support>
+#include <__utility/__decay_copy.h>
+#include <__utility/forward.h>
+#include <chrono>
#include <cstddef>
#include <functional>
+#include <iosfwd>
#include <memory>
#include <system_error>
-#include <chrono>
-#include <__mutex_base>
-#ifndef _LIBCPP_CXX03_LANG
#include <tuple>
-#endif
-#include <__threading_support>
-#include <__debug>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -346,7 +346,7 @@ thread::thread(_Fp __f)
__throw_system_error(__ec, "thread constructor failed");
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
inline _LIBCPP_INLINE_VISIBILITY
void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);}
@@ -362,12 +362,11 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d)
{
if (__d > chrono::duration<_Rep, _Period>::zero())
{
-#if defined(_LIBCPP_COMPILER_GCC) && (__powerpc__ || __POWERPC__)
- // GCC's long double const folding is incomplete for IBM128 long doubles.
- _LIBCPP_CONSTEXPR chrono::duration<long double> _Max = chrono::duration<long double>(ULLONG_MAX/1000000000ULL) ;
-#else
- _LIBCPP_CONSTEXPR chrono::duration<long double> _Max = chrono::nanoseconds::max();
-#endif
+ // The standard guarantees a 64bit signed integer resolution for nanoseconds,
+ // so use INT64_MAX / 1e9 as cut-off point. Use a constant to avoid <climits>
+ // and issues with long double folding on PowerPC with GCC.
+ _LIBCPP_CONSTEXPR chrono::duration<long double> _Max =
+ chrono::duration<long double>(9223372036.0L);
chrono::nanoseconds __ns;
if (__d < _Max)
{
@@ -411,4 +410,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_THREAD
+#endif // _LIBCPP_THREAD
diff --git a/contrib/llvm-project/libcxx/include/tuple b/contrib/llvm-project/libcxx/include/tuple
index c3c7db5ff118..e1019ef999d5 100644
--- a/contrib/llvm-project/libcxx/include/tuple
+++ b/contrib/llvm-project/libcxx/include/tuple
@@ -38,35 +38,39 @@ public:
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a);
template <class Alloc>
- explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...); // constexpr in C++20
template <class Alloc, class... U>
- explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...); // constexpr in C++20
template <class Alloc>
- tuple(allocator_arg_t, const Alloc& a, const tuple&);
+ tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20
template <class Alloc>
- tuple(allocator_arg_t, const Alloc& a, tuple&&);
+ tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20
template <class Alloc, class... U>
- explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20
template <class Alloc, class... U>
- explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20
template <class Alloc, class U1, class U2>
- explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20
template <class Alloc, class U1, class U2>
- explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20
- tuple& operator=(const tuple&);
- tuple&
- operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
+ tuple& operator=(const tuple&); // constexpr in C++20
+ tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20
template <class... U>
- tuple& operator=(const tuple<U...>&);
+ tuple& operator=(const tuple<U...>&); // constexpr in C++20
template <class... U>
- tuple& operator=(tuple<U...>&&);
+ tuple& operator=(tuple<U...>&&); // constexpr in C++20
template <class U1, class U2>
- tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
+ tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20
template <class U1, class U2>
- tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2
+ tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20
- void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
+ template<class U, size_t N>
+ tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION
+ template<class U, size_t N>
+ tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION
+
+ void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20
};
template <class ...T>
@@ -146,10 +150,16 @@ template <class... Types>
*/
#include <__config>
+#include <__functional/unwrap_ref.h>
+#include <__functional_base>
+#include <__memory/allocator_arg_t.h>
+#include <__memory/uses_allocator.h>
#include <__tuple>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <compare>
#include <cstddef>
#include <type_traits>
-#include <__functional_base>
#include <utility>
#include <version>
@@ -170,7 +180,7 @@ template <size_t _Ip, class _Hp,
class __tuple_leaf;
template <size_t _Ip, class _Hp, bool _Ep>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
_NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
{
@@ -191,29 +201,30 @@ class __tuple_leaf
#endif
}
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_leaf& operator=(const __tuple_leaf&);
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
+ _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
_NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_()
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
__tuple_leaf(integral_constant<int, 0>, const _Alloc&)
: __value_()
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
: __value_(allocator_arg_t(), __a)
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
: __value_(__a)
{static_assert(!is_reference<_Hp>::value,
@@ -234,21 +245,21 @@ public:
"Attempted construction of reference element binds to a temporary whose lifetime has ended");}
template <class _Tp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: __value_(_VSTD::forward<_Tp>(__t))
{static_assert(__can_bind_reference<_Tp&&>(),
"Attempted construction of reference element binds to a temporary whose lifetime has ended");}
template <class _Tp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
{static_assert(!is_reference<_Hp>::value,
"Attempted to uses-allocator construct a reference element in a tuple");}
template <class _Tp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: __value_(_VSTD::forward<_Tp>(__t), __a)
{static_assert(!is_reference<_Hp>::value,
@@ -257,16 +268,7 @@ public:
__tuple_leaf(const __tuple_leaf& __t) = default;
__tuple_leaf(__tuple_leaf&& __t) = default;
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- __tuple_leaf&
- operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
- {
- __value_ = _VSTD::forward<_Tp>(__t);
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
{
_VSTD::swap(*this, __t);
@@ -281,23 +283,23 @@ template <size_t _Ip, class _Hp>
class __tuple_leaf<_Ip, _Hp, true>
: private _Hp
{
-
+ _LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_leaf& operator=(const __tuple_leaf&);
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
+ _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
_NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
__tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
: _Hp(allocator_arg_t(), __a) {}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
: _Hp(__a) {}
@@ -314,33 +316,24 @@ public:
: _Hp(_VSTD::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: _Hp(_VSTD::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY constexpr
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: _Hp(_VSTD::forward<_Tp>(__t), __a) {}
__tuple_leaf(__tuple_leaf const &) = default;
__tuple_leaf(__tuple_leaf &&) = default;
- template <class _Tp>
- _LIBCPP_INLINE_VISIBILITY
- __tuple_leaf&
- operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
- {
- _Hp::operator=(_VSTD::forward<_Tp>(__t));
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
int
swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
{
@@ -353,7 +346,7 @@ public:
};
template <class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
void __swallow(_Tp&&...) _NOEXCEPT {}
template <class _Tp>
@@ -373,7 +366,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
: public __tuple_leaf<_Indx, _Tp>...
{
_LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __tuple_impl()
+ constexpr __tuple_impl()
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
template <size_t ..._Uf, class ..._Tf,
@@ -391,7 +384,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
template <class _Alloc, size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit
__tuple_impl(allocator_arg_t, const _Alloc& __a,
__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
@@ -421,7 +414,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
__tuple_constructible<_Tuple, tuple<_Tp...> >::value
>::type
>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
__tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(), __a,
@@ -429,49 +422,30 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
{}
- template <class _Tuple>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if
- <
- __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
- __tuple_impl&
- >::type
- operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
- typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
- {
- __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
- typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
- return *this;
- }
-
__tuple_impl(const __tuple_impl&) = default;
__tuple_impl(__tuple_impl&&) = default;
- _LIBCPP_INLINE_VISIBILITY
- __tuple_impl&
- operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
- {
- __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- __tuple_impl&
- operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
- {
- __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
void swap(__tuple_impl& __t)
_NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
{
- __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
+ _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
}
};
+template<class _Dest, class _Source, size_t ..._Np>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
+ _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);
+}
+template<class _Dest, class _Source, class ..._Up, size_t ..._Np>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
+ _VSTD::__swallow(((
+ _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))
+ ), void(), 0)...);
+}
template <class ..._Tp>
class _LIBCPP_TEMPLATE_VIS tuple
@@ -480,165 +454,6 @@ class _LIBCPP_TEMPLATE_VIS tuple
_BaseT __base_;
-#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
- static constexpr bool _EnableImplicitReducedArityExtension = true;
-#else
- static constexpr bool _EnableImplicitReducedArityExtension = false;
-#endif
-
- template <class ..._Args>
- struct _PackExpandsToThisTuple : false_type {};
-
- template <class _Arg>
- struct _PackExpandsToThisTuple<_Arg>
- : is_same<typename __uncvref<_Arg>::type, tuple> {};
-
- template <bool _MaybeEnable, class _Dummy = void>
- struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
-
- template <class _Dummy>
- struct _CheckArgsConstructor<true, _Dummy>
- {
- template <int&...>
- static constexpr bool __enable_implicit_default() {
- return __all<__is_implicitly_default_constructible<_Tp>::value... >::value;
- }
-
- template <int&...>
- static constexpr bool __enable_explicit_default() {
- return
- __all<is_default_constructible<_Tp>::value...>::value &&
- !__enable_implicit_default< >();
- }
-
-
- template <class ..._Args>
- static constexpr bool __enable_explicit() {
- return
- __tuple_constructible<
- tuple<_Args...>,
- typename __make_tuple_types<tuple,
- sizeof...(_Args) < sizeof...(_Tp) ?
- sizeof...(_Args) :
- sizeof...(_Tp)>::type
- >::value &&
- !__tuple_convertible<
- tuple<_Args...>,
- typename __make_tuple_types<tuple,
- sizeof...(_Args) < sizeof...(_Tp) ?
- sizeof...(_Args) :
- sizeof...(_Tp)>::type
- >::value &&
- __all_default_constructible<
- typename __make_tuple_types<tuple, sizeof...(_Tp),
- sizeof...(_Args) < sizeof...(_Tp) ?
- sizeof...(_Args) :
- sizeof...(_Tp)>::type
- >::value;
- }
-
- template <class ..._Args>
- static constexpr bool __enable_implicit() {
- return
- __tuple_constructible<
- tuple<_Args...>,
- typename __make_tuple_types<tuple,
- sizeof...(_Args) < sizeof...(_Tp) ?
- sizeof...(_Args) :
- sizeof...(_Tp)>::type
- >::value &&
- __tuple_convertible<
- tuple<_Args...>,
- typename __make_tuple_types<tuple,
- sizeof...(_Args) < sizeof...(_Tp) ?
- sizeof...(_Args) :
- sizeof...(_Tp)>::type
- >::value &&
- __all_default_constructible<
- typename __make_tuple_types<tuple, sizeof...(_Tp),
- sizeof...(_Args) < sizeof...(_Tp) ?
- sizeof...(_Args) :
- sizeof...(_Tp)>::type
- >::value;
- }
- };
-
- template <bool _MaybeEnable,
- bool = sizeof...(_Tp) == 1,
- class _Dummy = void>
- struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
-
- template <class _Dummy>
- struct _CheckTupleLikeConstructor<true, false, _Dummy>
- {
- template <class _Tuple>
- static constexpr bool __enable_implicit() {
- return __tuple_constructible<_Tuple, tuple>::value
- && __tuple_convertible<_Tuple, tuple>::value;
- }
-
- template <class _Tuple>
- static constexpr bool __enable_explicit() {
- return __tuple_constructible<_Tuple, tuple>::value
- && !__tuple_convertible<_Tuple, tuple>::value;
- }
- };
-
- template <class _Dummy>
- struct _CheckTupleLikeConstructor<true, true, _Dummy>
- {
- // This trait is used to disable the tuple-like constructor when
- // the UTypes... constructor should be selected instead.
- // See LWG issue #2549.
- template <class _Tuple>
- using _PreferTupleLikeConstructor = _Or<
- // Don't attempt the two checks below if the tuple we are given
- // has the same type as this tuple.
- _IsSame<__uncvref_t<_Tuple>, tuple>,
- _Lazy<_And,
- _Not<is_constructible<_Tp..., _Tuple>>,
- _Not<is_convertible<_Tuple, _Tp...>>
- >
- >;
-
- template <class _Tuple>
- static constexpr bool __enable_implicit() {
- return _And<
- __tuple_constructible<_Tuple, tuple>,
- __tuple_convertible<_Tuple, tuple>,
- _PreferTupleLikeConstructor<_Tuple>
- >::value;
- }
-
- template <class _Tuple>
- static constexpr bool __enable_explicit() {
- return _And<
- __tuple_constructible<_Tuple, tuple>,
- _PreferTupleLikeConstructor<_Tuple>,
- _Not<__tuple_convertible<_Tuple, tuple>>
- >::value;
- }
- };
-
- template <class _Tuple, bool _DisableIfLValue>
- using _EnableImplicitTupleLikeConstructor = _EnableIf<
- _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- && !_PackExpandsToThisTuple<_Tuple>::value
- && (!is_lvalue_reference<_Tuple>::value || !_DisableIfLValue)
- >::template __enable_implicit<_Tuple>(),
- bool
- >;
-
- template <class _Tuple, bool _DisableIfLValue>
- using _EnableExplicitTupleLikeConstructor = _EnableIf<
- _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- && !_PackExpandsToThisTuple<_Tuple>::value
- && (!is_lvalue_reference<_Tuple>::value || !_DisableIfLValue)
- >::template __enable_explicit<_Tuple>(),
- bool
- >;
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -648,57 +463,69 @@ class _LIBCPP_TEMPLATE_VIS tuple
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
public:
-
- template <bool _Dummy = true, _EnableIf<
- _CheckArgsConstructor<_Dummy>::__enable_implicit_default()
- , void*> = nullptr>
+ // [tuple.cnstr]
+
+ // tuple() constructors (including allocator_arg_t variants)
+ template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, _EnableIf<
+ _And<
+ _IsImpDefault<_Tp>... // explicit check
+ >::value
+ , int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
tuple()
- _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
-
- template <bool _Dummy = true, _EnableIf<
- _CheckArgsConstructor<_Dummy>::__enable_explicit_default()
- , void*> = nullptr>
- explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- tuple()
- _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
-
- tuple(tuple const&) = default;
- tuple(tuple&&) = default;
-
- template <class _AllocArgT, class _Alloc, _EnableIf<
- _CheckArgsConstructor<_IsSame<allocator_arg_t, _AllocArgT>::value >::__enable_implicit_default()
- , void*> = nullptr
- >
- _LIBCPP_INLINE_VISIBILITY
- tuple(_AllocArgT, _Alloc const& __a)
+ _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
+ { }
+
+ template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
+ template<class...> class _IsDefault = is_default_constructible, _EnableIf<
+ _And<
+ _IsDefault<_Tp>...,
+ _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ explicit tuple()
+ _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value)
+ { }
+
+ template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, _EnableIf<
+ _And<
+ _IsImpDefault<_Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, _Alloc const& __a)
: __base_(allocator_arg_t(), __a,
__tuple_indices<>(), __tuple_types<>(),
typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
__tuple_types<_Tp...>()) {}
- template <class _AllocArgT, class _Alloc, _EnableIf<
- _CheckArgsConstructor<_IsSame<allocator_arg_t, _AllocArgT>::value>::__enable_explicit_default()
- , void*> = nullptr
- >
- explicit _LIBCPP_INLINE_VISIBILITY
- tuple(_AllocArgT, _Alloc const& __a)
+ template <class _Alloc,
+ template<class...> class _IsImpDefault = __is_implicitly_default_constructible,
+ template<class...> class _IsDefault = is_default_constructible, _EnableIf<
+ _And<
+ _IsDefault<_Tp>...,
+ _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, _Alloc const& __a)
: __base_(allocator_arg_t(), __a,
__tuple_indices<>(), __tuple_types<>(),
typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
__tuple_types<_Tp...>()) {}
- template <bool _Dummy = true,
- typename enable_if
- <
- _CheckArgsConstructor<
- _Dummy
- >::template __enable_implicit<_Tp const&...>(),
- bool
- >::type = false
- >
+ // tuple(const T&...) constructors (including allocator_arg_t variants)
+ template <template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) >= 1>,
+ is_copy_constructible<_Tp>...,
+ is_convertible<const _Tp&, _Tp>... // explicit check
+ >::value
+ , int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
+ tuple(const _Tp& ... __t)
+ _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
: __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
@@ -706,17 +533,16 @@ public:
__t...
) {}
- template <bool _Dummy = true,
- typename enable_if
- <
- _CheckArgsConstructor<
- _Dummy
- >::template __enable_explicit<_Tp const&...>(),
- bool
- >::type = false
- >
+ template <template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) >= 1>,
+ is_copy_constructible<_Tp>...,
+ _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
+ explicit tuple(const _Tp& ... __t)
+ _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
: __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
@@ -724,17 +550,15 @@ public:
__t...
) {}
- template <class _Alloc, bool _Dummy = true,
- typename enable_if
- <
- _CheckArgsConstructor<
- _Dummy
- >::template __enable_implicit<_Tp const&...>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY
- tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
+ template <class _Alloc, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) >= 1>,
+ is_copy_constructible<_Tp>...,
+ is_convertible<const _Tp&, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
@@ -743,18 +567,15 @@ public:
__t...
) {}
- template <class _Alloc, bool _Dummy = true,
- typename enable_if
- <
- _CheckArgsConstructor<
- _Dummy
- >::template __enable_explicit<_Tp const&...>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY
- explicit
- tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
+ template <class _Alloc, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) >= 1>,
+ is_copy_constructible<_Tp>...,
+ _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
@@ -763,193 +584,493 @@ public:
__t...
) {}
- template <class ..._Up,
- bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
- typename enable_if
- <
- _CheckArgsConstructor<
- sizeof...(_Up) == sizeof...(_Tp)
- && !_PackIsTuple
- >::template __enable_implicit<_Up...>() ||
- _CheckArgsConstructor<
- _EnableImplicitReducedArityExtension
- && sizeof...(_Up) < sizeof...(_Tp)
- && !_PackIsTuple
- >::template __enable_implicit<_Up...>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- tuple(_Up&&... __u)
- _NOEXCEPT_((
- is_nothrow_constructible<_BaseT,
- typename __make_tuple_indices<sizeof...(_Up)>::type,
- typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
- typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
- typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
- _Up...
- >::value
- ))
- : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
+ // tuple(U&& ...) constructors (including allocator_arg_t variants)
+ template <class ..._Up> struct _IsThisTuple : false_type { };
+ template <class _Up> struct _IsThisTuple<_Up> : is_same<__uncvref_t<_Up>, tuple> { };
+
+ template <class ..._Up>
+ struct _EnableUTypesCtor : _And<
+ _BoolConstant<sizeof...(_Tp) >= 1>,
+ _Not<_IsThisTuple<_Up...> >, // extension to allow mis-behaved user constructors
+ is_constructible<_Tp, _Up>...
+ > { };
+
+ template <class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableUTypesCtor<_Up...>,
+ is_convertible<_Up, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ tuple(_Up&&... __u)
+ _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
+ : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
_VSTD::forward<_Up>(__u)...) {}
- template <class ..._Up,
- typename enable_if
- <
- _CheckArgsConstructor<
- sizeof...(_Up) <= sizeof...(_Tp)
- && !_PackExpandsToThisTuple<_Up...>::value
- >::template __enable_explicit<_Up...>() ||
- _CheckArgsConstructor<
- !_EnableImplicitReducedArityExtension
- && sizeof...(_Up) < sizeof...(_Tp)
- && !_PackExpandsToThisTuple<_Up...>::value
- >::template __enable_implicit<_Up...>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit
- tuple(_Up&&... __u)
- _NOEXCEPT_((
- is_nothrow_constructible<_BaseT,
- typename __make_tuple_indices<sizeof...(_Up)>::type,
- typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
- typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
- typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
- _Up...
- >::value
- ))
- : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
+ template <class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableUTypesCtor<_Up...>,
+ _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit tuple(_Up&&... __u)
+ _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
+ : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
_VSTD::forward<_Up>(__u)...) {}
- template <class _Alloc, class ..._Up,
- typename enable_if
- <
- _CheckArgsConstructor<
- sizeof...(_Up) == sizeof...(_Tp) &&
- !_PackExpandsToThisTuple<_Up...>::value
- >::template __enable_implicit<_Up...>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY
- tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
- : __base_(allocator_arg_t(), __a,
+ template <class _Alloc, class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableUTypesCtor<_Up...>,
+ is_convertible<_Up, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
+ : __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
_VSTD::forward<_Up>(__u)...) {}
- template <class _Alloc, class ..._Up,
- typename enable_if
- <
- _CheckArgsConstructor<
- sizeof...(_Up) == sizeof...(_Tp) &&
- !_PackExpandsToThisTuple<_Up...>::value
- >::template __enable_explicit<_Up...>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY
- explicit
- tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
- : __base_(allocator_arg_t(), __a,
+ template <class _Alloc, class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableUTypesCtor<_Up...>,
+ _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
+ : __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
_VSTD::forward<_Up>(__u)...) {}
- template <class _Tuple, _EnableImplicitTupleLikeConstructor<_Tuple, true> = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
- : __base_(_VSTD::forward<_Tuple>(__t)) {}
+ // Copy and move constructors (including the allocator_arg_t variants)
+ tuple(const tuple&) = default;
+ tuple(tuple&&) = default;
- template <class _Tuple, _EnableImplicitTupleLikeConstructor<const _Tuple&, false> = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- tuple(const _Tuple& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, const _Tuple&>::value))
- : __base_(__t) {}
- template <class _Tuple, _EnableExplicitTupleLikeConstructor<_Tuple, true> = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit
- tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, _Tuple>::value))
- : __base_(_VSTD::forward<_Tuple>(__t)) {}
+ template <class _Alloc, template<class...> class _And = _And, _EnableIf<
+ _And<is_copy_constructible<_Tp>...>::value
+ , int> = 0>
+ tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
+ : __base_(allocator_arg_t(), __alloc, __t)
+ { }
+
+ template <class _Alloc, template<class...> class _And = _And, _EnableIf<
+ _And<is_move_constructible<_Tp>...>::value
+ , int> = 0>
+ tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
+ : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
+ { }
+
+ // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
+ template <class ..._Up>
+ struct _EnableCopyFromOtherTuple : _And<
+ _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
+ _Lazy<_Or,
+ _BoolConstant<sizeof...(_Tp) != 1>,
+ // _Tp and _Up are 1-element packs - the pack expansions look
+ // weird to avoid tripping up the type traits in degenerate cases
+ _Lazy<_And,
+ _Not<is_convertible<const tuple<_Up>&, _Tp> >...,
+ _Not<is_constructible<_Tp, const tuple<_Up>&> >...
+ >
+ >,
+ is_constructible<_Tp, const _Up&>...
+ > { };
+
+ template <class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableCopyFromOtherTuple<_Up...>,
+ is_convertible<const _Up&, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ tuple(const tuple<_Up...>& __t)
+ _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
+ : __base_(__t)
+ { }
+
+ template <class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableCopyFromOtherTuple<_Up...>,
+ _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit tuple(const tuple<_Up...>& __t)
+ _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
+ : __base_(__t)
+ { }
+
+ template <class ..._Up, class _Alloc, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableCopyFromOtherTuple<_Up...>,
+ is_convertible<const _Up&, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
+ : __base_(allocator_arg_t(), __a, __t)
+ { }
+
+ template <class ..._Up, class _Alloc, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableCopyFromOtherTuple<_Up...>,
+ _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
+ : __base_(allocator_arg_t(), __a, __t)
+ { }
+
+ // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
+ template <class ..._Up>
+ struct _EnableMoveFromOtherTuple : _And<
+ _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >,
+ _Lazy<_Or,
+ _BoolConstant<sizeof...(_Tp) != 1>,
+ // _Tp and _Up are 1-element packs - the pack expansions look
+ // weird to avoid tripping up the type traits in degenerate cases
+ _Lazy<_And,
+ _Not<is_convertible<tuple<_Up>, _Tp> >...,
+ _Not<is_constructible<_Tp, tuple<_Up> > >...
+ >
+ >,
+ is_constructible<_Tp, _Up>...
+ > { };
+
+ template <class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableMoveFromOtherTuple<_Up...>,
+ is_convertible<_Up, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ tuple(tuple<_Up...>&& __t)
+ _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
+ : __base_(_VSTD::move(__t))
+ { }
+
+ template <class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableMoveFromOtherTuple<_Up...>,
+ _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit tuple(tuple<_Up...>&& __t)
+ _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
+ : __base_(_VSTD::move(__t))
+ { }
+
+ template <class _Alloc, class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableMoveFromOtherTuple<_Up...>,
+ is_convertible<_Up, _Tp>... // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
+ : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
+ { }
+
+ template <class _Alloc, class ..._Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>,
+ _EnableMoveFromOtherTuple<_Up...>,
+ _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
+ : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
+ { }
+
+ // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
+ template <class _Up1, class _Up2, class ..._DependentTp>
+ struct _EnableImplicitCopyFromPair : _And<
+ is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
+ is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
+ is_convertible<const _Up1&, _FirstType<_DependentTp...> >, // explicit check
+ is_convertible<const _Up2&, _SecondType<_DependentTp...> >
+ > { };
+
+ template <class _Up1, class _Up2, class ..._DependentTp>
+ struct _EnableExplicitCopyFromPair : _And<
+ is_constructible<_FirstType<_DependentTp...>, const _Up1&>,
+ is_constructible<_SecondType<_DependentTp...>, const _Up2&>,
+ _Not<is_convertible<const _Up1&, _FirstType<_DependentTp...> > >, // explicit check
+ _Not<is_convertible<const _Up2&, _SecondType<_DependentTp...> > >
+ > { };
+
+ template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ tuple(const pair<_Up1, _Up2>& __p)
+ _NOEXCEPT_((_And<
+ is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
+ is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
+ >::value))
+ : __base_(__p)
+ { }
+
+ template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit tuple(const pair<_Up1, _Up2>& __p)
+ _NOEXCEPT_((_And<
+ is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>,
+ is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&>
+ >::value))
+ : __base_(__p)
+ { }
+
+ template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
+ : __base_(allocator_arg_t(), __a, __p)
+ { }
+
+ template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
+ : __base_(allocator_arg_t(), __a, __p)
+ { }
+
+ // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants)
+ template <class _Up1, class _Up2, class ..._DependentTp>
+ struct _EnableImplicitMoveFromPair : _And<
+ is_constructible<_FirstType<_DependentTp...>, _Up1>,
+ is_constructible<_SecondType<_DependentTp...>, _Up2>,
+ is_convertible<_Up1, _FirstType<_DependentTp...> >, // explicit check
+ is_convertible<_Up2, _SecondType<_DependentTp...> >
+ > { };
+
+ template <class _Up1, class _Up2, class ..._DependentTp>
+ struct _EnableExplicitMoveFromPair : _And<
+ is_constructible<_FirstType<_DependentTp...>, _Up1>,
+ is_constructible<_SecondType<_DependentTp...>, _Up2>,
+ _Not<is_convertible<_Up1, _FirstType<_DependentTp...> > >, // explicit check
+ _Not<is_convertible<_Up2, _SecondType<_DependentTp...> > >
+ > { };
+
+ template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ tuple(pair<_Up1, _Up2>&& __p)
+ _NOEXCEPT_((_And<
+ is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
+ is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
+ >::value))
+ : __base_(_VSTD::move(__p))
+ { }
+
+ template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ explicit tuple(pair<_Up1, _Up2>&& __p)
+ _NOEXCEPT_((_And<
+ is_nothrow_constructible<_FirstType<_Tp...>, _Up1>,
+ is_nothrow_constructible<_SecondType<_Tp...>, _Up2>
+ >::value))
+ : __base_(_VSTD::move(__p))
+ { }
+
+ template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
+ : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
+ { }
+
+ template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...>
+ >::value
+ , int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
+ : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
+ { }
+
+ // [tuple.assign]
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
+ _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
+ {
+ _VSTD::__memberwise_copy_assign(*this, __tuple,
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
- template <class _Tuple, _EnableExplicitTupleLikeConstructor<const _Tuple&, false> = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit
- tuple(const _Tuple& __t) _NOEXCEPT_((is_nothrow_constructible<_BaseT, const _Tuple&>::value))
- : __base_(__t) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
+ _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
+ {
+ _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
+ __tuple_types<_Tp...>(),
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
- template <class _Alloc, class _Tuple,
- typename enable_if
- <
- _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- >::template __enable_implicit<_Tuple>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY
- tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
- : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
+ template<class... _Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
+ is_assignable<_Tp&, _Up const&>...
+ >::value
+ ,int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(tuple<_Up...> const& __tuple)
+ _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
+ {
+ _VSTD::__memberwise_copy_assign(*this, __tuple,
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
- template <class _Alloc, class _Tuple,
- typename enable_if
- <
- _CheckTupleLikeConstructor<
- __tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
- >::template __enable_explicit<_Tuple>(),
- bool
- >::type = false
- >
- _LIBCPP_INLINE_VISIBILITY
- explicit
- tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
- : __base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
+ template<class... _Up, _EnableIf<
+ _And<
+ _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>,
+ is_assignable<_Tp&, _Up>...
+ >::value
+ ,int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(tuple<_Up...>&& __tuple)
+ _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
+ {
+ _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__tuple),
+ __tuple_types<_Up...>(),
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
- using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
- using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
+ template<class _Up1, class _Up2, class _Dep = true_type, _EnableIf<
+ _And<_Dep,
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>,
+ is_assignable<_SecondType<_Tp..., _Dep>&, _Up2 const&>
+ >::value
+ ,int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(pair<_Up1, _Up2> const& __pair)
+ _NOEXCEPT_((_And<
+ is_nothrow_assignable<_FirstType<_Tp...>&, _Up1 const&>,
+ is_nothrow_assignable<_SecondType<_Tp...>&, _Up2 const&>
+ >::value))
+ {
+ _VSTD::get<0>(*this) = __pair.first;
+ _VSTD::get<1>(*this) = __pair.second;
+ return *this;
+ }
- _LIBCPP_INLINE_VISIBILITY
- tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
- _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
+ template<class _Up1, class _Up2, class _Dep = true_type, _EnableIf<
+ _And<_Dep,
+ _BoolConstant<sizeof...(_Tp) == 2>,
+ is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>,
+ is_assignable<_SecondType<_Tp..., _Dep>&, _Up2>
+ >::value
+ ,int> = 0>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(pair<_Up1, _Up2>&& __pair)
+ _NOEXCEPT_((_And<
+ is_nothrow_assignable<_FirstType<_Tp...>&, _Up1>,
+ is_nothrow_assignable<_SecondType<_Tp...>&, _Up2>
+ >::value))
{
- __base_.operator=(__t.__base_);
+ _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first);
+ _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second);
return *this;
}
- _LIBCPP_INLINE_VISIBILITY
- tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
- _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
+ // EXTENSION
+ template<class _Up, size_t _Np, class = _EnableIf<
+ _And<
+ _BoolConstant<_Np == sizeof...(_Tp)>,
+ is_assignable<_Tp&, _Up const&>...
+ >::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(array<_Up, _Np> const& __array)
+ _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
{
- __base_.operator=(static_cast<_BaseT&&>(__t.__base_));
+ _VSTD::__memberwise_copy_assign(*this, __array,
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
return *this;
}
- template <class _Tuple,
- class = typename enable_if
- <
- __tuple_assignable<_Tuple, tuple>::value
- >::type
- >
- _LIBCPP_INLINE_VISIBILITY
- tuple&
- operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<_BaseT&, _Tuple>::value))
- {
- __base_.operator=(_VSTD::forward<_Tuple>(__t));
- return *this;
- }
+ // EXTENSION
+ template<class _Up, size_t _Np, class = void, class = _EnableIf<
+ _And<
+ _BoolConstant<_Np == sizeof...(_Tp)>,
+ is_assignable<_Tp&, _Up>...
+ >::value
+ > >
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+ tuple& operator=(array<_Up, _Np>&& __array)
+ _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
+ {
+ _VSTD::__memberwise_forward_assign(*this, _VSTD::move(__array),
+ __tuple_types<_If<true, _Up, _Tp>...>(),
+ typename __make_tuple_indices<sizeof...(_Tp)>::type());
+ return *this;
+ }
- _LIBCPP_INLINE_VISIBILITY
+ // [tuple.swap]
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
{__base_.swap(__t.__base_);}
};
@@ -958,21 +1079,21 @@ template <>
class _LIBCPP_TEMPLATE_VIS tuple<>
{
public:
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR tuple() _NOEXCEPT = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ tuple() _NOEXCEPT = default;
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
template <class _Alloc>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
template <class _Up>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple(array<_Up, 0>) _NOEXCEPT {}
template <class _Alloc, class _Up>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
void swap(tuple&) _NOEXCEPT {}
};
@@ -990,7 +1111,7 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
#endif
template <class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if
<
__all<__is_swappable<_Tp>::value...>::value,
@@ -1044,7 +1165,7 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT
namespace __find_detail {
-static constexpr size_t __not_found = -1;
+static constexpr size_t __not_found = static_cast<size_t>(-1);
static constexpr size_t __ambiguous = __not_found - 1;
inline _LIBCPP_INLINE_VISIBILITY
@@ -1450,4 +1571,4 @@ _LIBCPP_NOEXCEPT_RETURN(
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_TUPLE
+#endif // _LIBCPP_TUPLE
diff --git a/contrib/llvm-project/libcxx/include/type_traits b/contrib/llvm-project/libcxx/include/type_traits
index 59dfd1e9bae6..b15c7a2a5f35 100644
--- a/contrib/llvm-project/libcxx/include/type_traits
+++ b/contrib/llvm-project/libcxx/include/type_traits
@@ -99,7 +99,7 @@ namespace std
template <class T> struct is_trivial;
template <class T> struct is_trivially_copyable;
template <class T> struct is_standard_layout;
- template <class T> struct is_literal_type;
+ template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20
template <class T> struct is_empty;
template <class T> struct is_polymorphic;
template <class T> struct is_abstract;
@@ -165,8 +165,8 @@ namespace std
template <class T> struct decay;
template <class... T> struct common_type;
template <class T> struct underlying_type;
- template <class> class result_of; // undefined
- template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
+ template <class> class result_of; // undefined; deprecated in C++17; removed in C++20
+ template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20
template <class Fn, class... ArgTypes> struct invoke_result; // C++17
// const-volatile modifications:
@@ -216,9 +216,9 @@ namespace std
using add_pointer_t = typename add_pointer<T>::type; // C++14
// other transformations:
- template <size_t Len, std::size_t Align=default-alignment>
+ template <size_t Len, size_t Align=default-alignment>
using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
- template <std::size_t Len, class... Types>
+ template <size_t Len, class... Types>
using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
template <class T>
using remove_cvref_t = typename remove_cvref<T>::type; // C++20
@@ -233,7 +233,7 @@ namespace std
template <class T>
using underlying_type_t = typename underlying_type<T>::type; // C++14
template <class T>
- using result_of_t = typename result_of<T>::type; // C++14
+ using result_of_t = typename result_of<T>::type; // C++14; deprecated in C++17; removed in C++20
template <class Fn, class... ArgTypes>
using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
@@ -302,7 +302,7 @@ namespace std
template <class T> inline constexpr bool is_pod_v
= is_pod<T>::value; // C++17
template <class T> inline constexpr bool is_literal_type_v
- = is_literal_type<T>::value; // C++17
+ = is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20
template <class T> inline constexpr bool is_empty_v
= is_empty<T>::value; // C++17
template <class T> inline constexpr bool is_polymorphic_v
@@ -476,8 +476,6 @@ struct _MetaBase<true> {
using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp;
template <class _Result, class _First, class ..._Rest>
using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>;
- template <class _Result, class _First, class ..._Rest>
- using _AndImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value == true && sizeof...(_Rest) != 0>::template _AndImpl<_First, _Rest...>;
};
template <>
@@ -488,8 +486,6 @@ struct _MetaBase<false> {
using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>;
template <class _Result, class ...>
using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result;
- template <class _Result, class ...>
- using _AndImpl _LIBCPP_NODEBUG_TYPE = _Result;
};
template <bool _Cond, class _Ret = void>
using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>;
@@ -497,8 +493,6 @@ template <bool _Cond, class _IfRes, class _ElseRes>
using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>;
template <class ..._Rest>
using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>;
-template <class ..._Rest>
-using _And _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _AndImpl<true_type, _Rest...>;
template <class _Pred>
struct _Not : _BoolConstant<!_Pred::value> {};
template <class ..._Args>
@@ -506,6 +500,14 @@ using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >=
template <class ..._Args>
using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>;
+template <class ...> using __expand_to_true = true_type;
+template <class ..._Pred>
+__expand_to_true<_EnableIf<_Pred::value>...> __and_helper(int);
+template <class ...>
+false_type __and_helper(...);
+template <class ..._Pred>
+using _And _LIBCPP_NODEBUG_TYPE = decltype(__and_helper<_Pred...>(0));
+
template <template <class...> class _Func, class ..._Args>
struct _Lazy : _Func<_Args...> {};
@@ -525,6 +527,9 @@ struct __void_t { typedef void type; };
template <class _Tp>
struct __identity { typedef _Tp type; };
+template <class _Tp>
+using __identity_t _LIBCPP_NODEBUG_TYPE = typename __identity<_Tp>::type;
+
template <class _Tp, bool>
struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
@@ -575,7 +580,7 @@ using _IsSame = _BoolConstant<
#ifdef __clang__
__is_same(_Tp, _Up)
#else
- _VSTD::is_same<_Tp, _Up>::value
+ is_same<_Tp, _Up>::value
#endif
>;
@@ -584,7 +589,7 @@ using _IsNotSame = _BoolConstant<
#ifdef __clang__
!__is_same(_Tp, _Up)
#else
- !_VSTD::is_same<_Tp, _Up>::value
+ !is_same<_Tp, _Up>::value
#endif
>;
@@ -784,6 +789,33 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v
#endif // __has_keyword(__is_integral)
+// __libcpp_is_signed_integer, __libcpp_is_unsigned_integer
+
+// [basic.fundamental] defines five standard signed integer types;
+// __int128_t is an extended signed integer type.
+// The signed and unsigned integer types, plus bool and the
+// five types with "char" in their name, compose the "integral" types.
+
+template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
+template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
+template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
+#endif
+
+template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
+template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
+#endif
+
// is_floating_point
template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
@@ -831,8 +863,10 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v
// is_pointer
-// In clang 10.0.0 and earlier __is_pointer didn't work with Objective-C types.
-#if __has_keyword(__is_pointer) && _LIBCPP_CLANG_VER > 1000
+// Before Clang 11 / AppleClang 12.0.5, __is_pointer didn't work for Objective-C types.
+#if __has_keyword(__is_pointer) && \
+ !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1100) && \
+ !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
@@ -1126,9 +1160,11 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v
// is_fundamental
-// In clang 9 and lower, this builtin did not work for nullptr_t. Additionally, in C++03 mode,
-// nullptr isn't defined by the compiler so, this builtin won't work.
-#if __has_keyword(__is_fundamental) && _LIBCPP_CLANG_VER > 900 && !defined(_LIBCPP_CXX03_LANG)
+// Before Clang 10, __is_fundamental didn't work for nullptr_t.
+// In C++03 nullptr_t is library-provided but must still count as "fundamental."
+#if __has_keyword(__is_fundamental) && \
+ !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \
+ !defined(_LIBCPP_CXX03_LANG)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
@@ -1155,7 +1191,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v
// is_scalar
-// >= 11 because in C++03 nullptr isn't actually nullptr
+// In C++03 nullptr_t is library-provided but must still count as "scalar."
#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
template<class _Tp>
@@ -1335,7 +1371,7 @@ template <class _Tp> _Tp __declval(long);
_LIBCPP_SUPPRESS_DEPRECATED_POP
template <class _Tp>
-decltype(_VSTD::__declval<_Tp>(0))
+decltype(__declval<_Tp>(0))
declval() _NOEXCEPT;
// __uncvref
@@ -1412,8 +1448,9 @@ template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type;
// is_signed
-// In clang 9 and earlier, this builtin did not work for floating points or enums
-#if __has_keyword(__is_signed) && _LIBCPP_CLANG_VER > 900
+// Before Clang 10, __is_signed didn't work for floating-point types or enums.
+#if __has_keyword(__is_signed) && \
+ !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
@@ -1448,7 +1485,11 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v
// is_unsigned
-#if __has_keyword(__is_unsigned)
+// Before Clang 13, __is_unsigned returned true for enums with signed underlying type.
+// No currently-released version of AppleClang contains the fixed intrinsic.
+#if __has_keyword(__is_unsigned) && \
+ !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \
+ !defined(_LIBCPP_APPLE_CLANG_VER)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
@@ -1698,7 +1739,7 @@ struct __is_convertible_test : public false_type {};
template <class _From, class _To>
struct __is_convertible_test<_From, _To,
- decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
+ decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
{};
template <class _Tp, bool _IsArray = is_array<_Tp>::value,
@@ -1754,7 +1795,7 @@ template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
};
-#endif // __has_feature(is_convertible_to)
+#endif // __has_feature(is_convertible_to)
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _From, class _To>
@@ -1817,7 +1858,7 @@ template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {};
-#endif // __has_feature(is_empty)
+#endif // __has_feature(is_empty)
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
@@ -2297,6 +2338,14 @@ struct _LIBCPP_TEMPLATE_VIS make_unsigned
template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
#endif
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Tp>
+_LIBCPP_NODISCARD_ATTRIBUTE _LIBCPP_INLINE_VISIBILITY constexpr
+typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
+ return static_cast<typename make_unsigned<_Tp>::type>(__x);
+}
+#endif
+
#if _LIBCPP_STD_VER > 14
template <class...> using void_t = void;
#endif
@@ -2304,7 +2353,7 @@ template <class...> using void_t = void;
#if _LIBCPP_STD_VER > 17
// Let COND_RES(X, Y) be:
template <class _Tp, class _Up>
-using __cond_type = decltype(false ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>());
+using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
template <class _Tp, class _Up, class = void>
struct __common_type3 {};
@@ -2327,11 +2376,11 @@ struct __common_type2_imp {};
template <class _Tp, class _Up>
struct __common_type2_imp<_Tp, _Up,
typename __void_t<decltype(
- true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
+ true ? declval<_Tp>() : declval<_Up>()
)>::type>
{
typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype(
- true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>()
+ true ? declval<_Tp>() : declval<_Up>()
)>::type type;
};
@@ -2411,6 +2460,216 @@ struct _LIBCPP_TEMPLATE_VIS
template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
#endif
+#if _LIBCPP_STD_VER > 11
+// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
+// top-level cv-qualifiers.
+template <class _From, class _To>
+struct __copy_cv
+{
+ using type = _To;
+};
+
+template <class _From, class _To>
+struct __copy_cv<const _From, _To>
+{
+ using type = add_const_t<_To>;
+};
+
+template <class _From, class _To>
+struct __copy_cv<volatile _From, _To>
+{
+ using type = add_volatile_t<_To>;
+};
+
+template <class _From, class _To>
+struct __copy_cv<const volatile _From, _To>
+{
+ using type = add_cv_t<_To>;
+};
+
+template <class _From, class _To>
+using __copy_cv_t = typename __copy_cv<_From, _To>::type;
+
+template <class _From, class _To>
+struct __copy_cvref
+{
+ using type = __copy_cv_t<_From, _To>;
+};
+
+template <class _From, class _To>
+struct __copy_cvref<_From&, _To>
+{
+ using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>;
+};
+
+template <class _From, class _To>
+struct __copy_cvref<_From&&, _To>
+{
+ using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>;
+};
+
+template <class _From, class _To>
+using __copy_cvref_t = typename __copy_cvref<_From, _To>::type;
+
+#endif // _LIBCPP_STD_VER > 11
+
+// common_reference
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+// Let COND_RES(X, Y) be:
+template <class _Xp, class _Yp>
+using __cond_res =
+ decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
+
+// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
+// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
+// `U`.
+// [Note: `XREF(A)` is `__xref<A>::template __apply`]
+template <class _Tp>
+struct __xref {
+ template<class _Up>
+ using __apply = __copy_cvref_t<_Tp, _Up>;
+};
+
+// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
+// and let COMMON-REF(A, B) be:
+template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>>
+struct __common_ref;
+
+template<class _Xp, class _Yp>
+using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type;
+
+template<class _Xp, class _Yp>
+using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>;
+
+
+// If A and B are both lvalue reference types, COMMON-REF(A, B) is
+// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>>
+struct __common_ref<_Ap&, _Bp&, _Xp, _Yp>
+{
+ using __type = __cv_cond_res<_Xp, _Yp>;
+};
+
+// Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ...
+template <class _Xp, class _Yp>
+using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&;
+
+
+// .... If A and B are both rvalue reference types, C is well-formed, and
+// is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+requires
+ requires { typename __common_ref_C<_Xp, _Yp>; } &&
+ is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> &&
+ is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>>
+struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp>
+{
+ using __type = __common_ref_C<_Xp, _Yp>;
+};
+
+// Otherwise, let D be COMMON-REF(const X&, Y&). ...
+template <class _Tp, class _Up>
+using __common_ref_D = __common_ref_t<const _Tp&, _Up&>;
+
+// ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and
+// is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+requires requires { typename __common_ref_D<_Xp, _Yp>; } &&
+ is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>>
+struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp>
+{
+ using __type = __common_ref_D<_Xp, _Yp>;
+};
+
+// Otherwise, if A is an lvalue reference and B is an rvalue reference, then
+// COMMON-REF(A, B) is COMMON-REF(B, A).
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {};
+
+// Otherwise, COMMON-REF(A, B) is ill-formed.
+template<class _Ap, class _Bp, class _Xp, class _Yp>
+struct __common_ref {};
+
+// Note C: For the common_reference trait applied to a parameter pack [...]
+
+template <class...>
+struct common_reference;
+
+template <class... _Types>
+using common_reference_t = typename common_reference<_Types...>::type;
+
+// bullet 1 - sizeof...(T) == 0
+template<>
+struct common_reference<> {};
+
+// bullet 2 - sizeof...(T) == 1
+template <class _Tp>
+struct common_reference<_Tp>
+{
+ using type = _Tp;
+};
+
+// bullet 3 - sizeof...(T) == 2
+template <class _Tp, class _Up> struct __common_reference_sub_bullet3;
+template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {};
+template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
+
+// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then
+// the member typedef `type` denotes that type.
+template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
+
+template <class _Tp, class _Up>
+requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
+struct __common_reference_sub_bullet1<_Tp, _Up>
+{
+ using type = __common_ref_t<_Tp, _Up>;
+};
+
+// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
+// is well-formed, then the member typedef `type` denotes that type.
+template <class, class, template <class> class, template <class> class> struct basic_common_reference {};
+
+template <class _Tp, class _Up>
+using __basic_common_reference_t = typename basic_common_reference<
+ remove_cvref_t<_Tp>, remove_cvref_t<_Up>,
+ __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type;
+
+template <class _Tp, class _Up>
+requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
+struct __common_reference_sub_bullet2<_Tp, _Up>
+{
+ using type = __basic_common_reference_t<_Tp, _Up>;
+};
+
+// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
+// then the member typedef `type` denotes that type.
+template <class _Tp, class _Up>
+requires requires { typename __cond_res<_Tp, _Up>; }
+struct __common_reference_sub_bullet3<_Tp, _Up>
+{
+ using type = __cond_res<_Tp, _Up>;
+};
+
+
+// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
+// then the member typedef `type` denotes that type.
+// - Otherwise, there shall be no member `type`.
+template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
+
+// bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if
+// any, as `common_reference_t<C, Rest...>`.
+template <class _Tp, class _Up, class _Vp, class... _Rest>
+requires requires { typename common_reference_t<_Tp, _Up>; }
+struct common_reference<_Tp, _Up, _Vp, _Rest...>
+ : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...>
+{};
+
+// bullet 5 - Otherwise, there shall be no member `type`.
+template <class...> struct common_reference {};
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS)
+
// is_assignable
template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
@@ -2428,7 +2687,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v = __is_assignable(_Tp,
#else // __has_keyword(__is_assignable)
template <class _Tp, class _Arg>
-typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
+typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
__is_assignable_test(int);
template <class, class>
@@ -2455,7 +2714,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v
= is_assignable<_Tp, _Arg>::value;
#endif
-#endif // __has_keyword(__is_assignable)
+#endif // __has_keyword(__is_assignable)
// is_copy_assignable
@@ -2509,7 +2768,7 @@ template <typename _Tp>
struct __is_destructor_wellformed {
template <typename _Tp1>
static char __test (
- typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
+ typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
);
template <typename _Tp1>
@@ -2523,33 +2782,33 @@ struct __destructible_imp;
template <class _Tp>
struct __destructible_imp<_Tp, false>
- : public _VSTD::integral_constant<bool,
- __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
+ : public integral_constant<bool,
+ __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
template <class _Tp>
struct __destructible_imp<_Tp, true>
- : public _VSTD::true_type {};
+ : public true_type {};
template <class _Tp, bool>
struct __destructible_false;
template <class _Tp>
-struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
+struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};
template <class _Tp>
-struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
+struct __destructible_false<_Tp, true> : public false_type {};
template <class _Tp>
struct is_destructible
- : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
+ : public __destructible_false<_Tp, is_function<_Tp>::value> {};
template <class _Tp>
struct is_destructible<_Tp[]>
- : public _VSTD::false_type {};
+ : public false_type {};
template <>
struct is_destructible<void>
- : public _VSTD::false_type {};
+ : public false_type {};
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
@@ -2559,43 +2818,6 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v
#endif // __has_keyword(__is_destructible)
-// move
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename remove_reference<_Tp>::type&&
-move(_Tp&& __t) _NOEXCEPT
-{
- typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up;
- return static_cast<_Up&&>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-_Tp&&
-forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT
-{
- return static_cast<_Tp&&>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-_Tp&&
-forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT
-{
- static_assert(!is_lvalue_reference<_Tp>::value,
- "can not forward an rvalue as an lvalue");
- return static_cast<_Tp&&>(__t);
-}
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename decay<_Tp>::type
-__decay_copy(_Tp&& __t)
-{
- return _VSTD::forward<_Tp>(__t);
-}
-
template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
struct __member_pointer_traits_imp
{
@@ -2795,7 +3017,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
typedef _Rp (_FnType) (_Param..., ...);
};
-#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
+#endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC)
template <class _Rp, class _Class>
@@ -2876,11 +3098,11 @@ struct __is_constructible_helper
// NOTE: The static_cast implementation below is required to support
// classes with explicit conversion operators.
template <class _To, class _From,
- class = decltype(__eat<_To>(_VSTD::declval<_From>()))>
+ class = decltype(__eat<_To>(declval<_From>()))>
static true_type __test_cast(int);
template <class _To, class _From,
- class = decltype(static_cast<_To>(_VSTD::declval<_From>()))>
+ class = decltype(static_cast<_To>(declval<_From>()))>
static integral_constant<bool,
!__is_invalid_base_to_derived_cast<_To, _From>::value &&
!__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
@@ -2890,12 +3112,12 @@ struct __is_constructible_helper
static false_type __test_cast(...);
template <class _Tp, class ..._Args,
- class = decltype(_Tp(_VSTD::declval<_Args>()...))>
+ class = decltype(_Tp(declval<_Args>()...))>
static true_type __test_nary(int);
template <class _Tp, class...>
static false_type __test_nary(...);
- template <class _Tp, class _A0, class = decltype(::new _Tp(_VSTD::declval<_A0>()))>
+ template <class _Tp, class _A0, class = decltype(::new _Tp(declval<_A0>()))>
static is_destructible<_Tp> __test_unary(int);
template <class, class>
static false_type __test_unary(...);
@@ -2984,18 +3206,18 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v
template <class _Tp>
void __test_implicit_default_constructible(_Tp);
-template <class _Tp, class = void, bool = is_default_constructible<_Tp>::value>
+template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
struct __is_implicitly_default_constructible
: false_type
{ };
template <class _Tp>
-struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true>
+struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
: true_type
{ };
template <class _Tp>
-struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false>
+struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
: false_type
{ };
#endif // !C++03
@@ -3072,7 +3294,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&>
{
};
-#endif // !__has_feature(is_trivially_constructible)
+#endif // !__has_feature(is_trivially_constructible)
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
@@ -3149,7 +3371,7 @@ template <class _Tp>
struct is_trivially_assignable<_Tp&, _Tp&&>
: integral_constant<bool, is_scalar<_Tp>::value> {};
-#endif // !__has_feature(is_trivially_assignable)
+#endif // !__has_feature(is_trivially_assignable)
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp, class _Arg>
@@ -3259,7 +3481,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
{
};
-#endif // _LIBCPP_HAS_NO_NOEXCEPT
+#endif // _LIBCPP_HAS_NO_NOEXCEPT
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
@@ -3324,7 +3546,7 @@ struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
template <class _Tp, class _Arg>
struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
- : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
+ : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
{
};
@@ -3334,7 +3556,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
{
};
-#endif // _LIBCPP_HAS_NO_NOEXCEPT
+#endif // _LIBCPP_HAS_NO_NOEXCEPT
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp, class _Arg>
@@ -3381,7 +3603,7 @@ struct __libcpp_is_nothrow_destructible<false, _Tp>
template <class _Tp>
struct __libcpp_is_nothrow_destructible<true, _Tp>
- : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
+ : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
{
};
@@ -3455,15 +3677,17 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v
// is_literal_type;
-template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
+template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
: public integral_constant<bool, __is_literal_type(_Tp)>
{};
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
-_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
+_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v
= is_literal_type<_Tp>::value;
-#endif
+#endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
// is_standard_layout;
@@ -3604,42 +3828,42 @@ template <class _Fp, class _A0, class ..._Args,
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet1<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet2<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(static_cast<_Args&&>(__args)...))
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet2<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN((__a0.get().*__f)(static_cast<_Args&&>(__args)...))
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet3<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet3<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))
// bullets 4, 5 and 6
@@ -3648,14 +3872,14 @@ template <class _Fp, class _A0,
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0)
-_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
+_LIBCPP_INVOKE_RETURN(static_cast<_A0&&>(__a0).*__f)
template <class _Fp, class _A0,
class = __enable_if_bullet4<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
-_LIBCPP_INVOKE_RETURN(_VSTD::forward<_A0>(__a0).*__f)
+_LIBCPP_INVOKE_RETURN(static_cast<_A0&&>(__a0).*__f)
template <class _Fp, class _A0,
class = __enable_if_bullet5<_Fp, _A0>>
@@ -3676,14 +3900,14 @@ template <class _Fp, class _A0,
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _A0&& __a0)
-_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
+_LIBCPP_INVOKE_RETURN((*static_cast<_A0&&>(__a0)).*__f)
template <class _Fp, class _A0,
class = __enable_if_bullet6<_Fp, _A0>>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
-_LIBCPP_INVOKE_RETURN((*_VSTD::forward<_A0>(__a0)).*__f)
+_LIBCPP_INVOKE_RETURN((*static_cast<_A0&&>(__a0)).*__f)
// bullet 7
@@ -3691,13 +3915,13 @@ template <class _Fp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 auto
__invoke(_Fp&& __f, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
template <class _Fp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR auto
__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
-_LIBCPP_INVOKE_RETURN(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...))
+_LIBCPP_INVOKE_RETURN(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))
#undef _LIBCPP_INVOKE_RETURN
@@ -3707,7 +3931,7 @@ struct __invokable_r
{
template <class _XFp, class ..._XArgs>
static auto __try_call(int) -> decltype(
- _VSTD::__invoke(_VSTD::declval<_XFp>(), _VSTD::declval<_XArgs>()...));
+ _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...));
template <class _XFp, class ..._XArgs>
static __nat __try_call(...);
@@ -3744,14 +3968,14 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
static void __test_noexcept(_Tp) noexcept;
static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
- _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)));
+ _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
};
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
static const bool value = noexcept(
- _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
+ _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
};
template <class _Ret, class _Fp, class ..._Args>
@@ -3781,7 +4005,8 @@ struct __invoke_of
// result_of
-template <class _Callable> class result_of;
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
+template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
#ifndef _LIBCPP_CXX03_LANG
@@ -3812,8 +4037,8 @@ struct __result_of_mp;
template <class _MP, class _Tp>
struct __result_of_mp<_MP, _Tp, true>
- : public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
{
+ using type = typename __member_pointer_traits<_MP>::_ReturnType;
};
// member data pointer
@@ -3824,13 +4049,13 @@ struct __result_of_mdp;
template <class _Rp, class _Class, class _Tp>
struct __result_of_mdp<_Rp _Class::*, _Tp, false>
{
- typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
+ using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&;
};
template <class _Rp, class _Class, class _Tp>
struct __result_of_mdp<_Rp _Class::*, _Tp, true>
{
- typedef typename __apply_cv<_Tp, _Rp>::type& type;
+ using type = typename __apply_cv<_Tp, _Rp>::type&;
};
template <class _Rp, class _Class, class _Tp>
@@ -3866,11 +4091,12 @@ class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)>
{
};
-#endif // C++03
+#endif // C++03
#if _LIBCPP_STD_VER > 11
-template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
-#endif
+template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
+#endif // _LIBCPP_STD_VER > 11
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
#if _LIBCPP_STD_VER > 14
@@ -3923,70 +4149,32 @@ _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v
#endif // _LIBCPP_STD_VER > 14
+// __swappable
+
template <class _Tp> struct __is_swappable;
template <class _Tp> struct __is_nothrow_swappable;
-// swap, swap_ranges
-template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator2
-swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2);
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_CXX03_LANG
-typename enable_if
-<
- is_move_constructible<_Tp>::value &&
- is_move_assignable<_Tp>::value
->::type
+template <class _Tp>
+using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
#else
-void
+template <class>
+using __swap_result_t = void;
#endif
-_LIBCPP_CONSTEXPR_AFTER_CXX17
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
- is_nothrow_move_assignable<_Tp>::value)
-{
- _Tp __t(_VSTD::move(__x));
- __x = _VSTD::move(__y);
- __y = _VSTD::move(__t);
-}
+ is_nothrow_move_assignable<_Tp>::value);
template<class _Tp, size_t _Np>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename enable_if<
__is_swappable<_Tp>::value
>::type
-swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
-{
- _VSTD::swap_ranges(__a, __a + _Np, __b);
-}
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator2
-swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
-{
- for(; __first1 != __last1; ++__first1, (void) ++__first2)
- swap(*__first1, *__first2);
- return __first2;
-}
-
-// iter_swap
-
-template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-void
-iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
- // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
- _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
- *_VSTD::declval<_ForwardIterator2>())))
-{
- swap(*__a, *__b);
-}
-
-// __swappable
+swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
namespace __detail
{
@@ -3997,7 +4185,7 @@ template <class _Tp, class _Up = _Tp,
struct __swappable_with
{
template <class _LHS, class _RHS>
- static decltype(swap(_VSTD::declval<_LHS>(), _VSTD::declval<_RHS>()))
+ static decltype(swap(declval<_LHS>(), declval<_RHS>()))
__test_swap(int);
template <class, class>
static __nat __test_swap(long);
@@ -4017,8 +4205,8 @@ template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _U
struct __nothrow_swappable_with {
static const bool value =
#ifndef _LIBCPP_HAS_NO_NOEXCEPT
- noexcept(swap(_VSTD::declval<_Tp>(), _VSTD::declval<_Up>()))
- && noexcept(swap(_VSTD::declval<_Up>(), _VSTD::declval<_Tp>()));
+ noexcept(swap(declval<_Tp>(), declval<_Up>()))
+ && noexcept(swap(declval<_Up>(), declval<_Tp>()));
#else
false;
#endif
@@ -4168,7 +4356,7 @@ struct __has_operator_addressof_member_imp
{
template <class _Up>
static auto __test(int)
- -> typename __select_2nd<decltype(_VSTD::declval<_Up>().operator&()), true_type>::type;
+ -> typename __select_2nd<decltype(declval<_Up>().operator&()), true_type>::type;
template <class>
static auto __test(long) -> false_type;
@@ -4180,7 +4368,7 @@ struct __has_operator_addressof_free_imp
{
template <class _Up>
static auto __test(int)
- -> typename __select_2nd<decltype(operator&(_VSTD::declval<_Up>())), true_type>::type;
+ -> typename __select_2nd<decltype(operator&(declval<_Up>())), true_type>::type;
template <class>
static auto __test(long) -> false_type;
@@ -4193,7 +4381,7 @@ struct __has_operator_addressof
|| __has_operator_addressof_free_imp<_Tp>::value>
{};
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// is_scoped_enum [meta.unary.prop]
@@ -4233,7 +4421,7 @@ struct negation : _Not<_Tp> {};
template<class _Tp>
_LIBCPP_INLINE_VAR constexpr bool negation_v
= negation<_Tp>::value;
-#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER > 14
// These traits are used in __tree and __hash_table
struct __extract_key_fail_tag {};
@@ -4283,6 +4471,14 @@ bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; }
template <class _CharT>
using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
+template<class _Tp>
+using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
+
+#if _LIBCPP_STD_VER > 17
+template<bool _Const, class _Tp>
+using __maybe_const = conditional_t<_Const, const _Tp, _Tp>;
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
@@ -4294,4 +4490,4 @@ namespace std // purposefully not versioned
}
#endif
-#endif // _LIBCPP_TYPE_TRAITS
+#endif // _LIBCPP_TYPE_TRAITS
diff --git a/contrib/llvm-project/libcxx/include/typeindex b/contrib/llvm-project/libcxx/include/typeindex
index bff1e65af944..88bb9ef03d61 100644
--- a/contrib/llvm-project/libcxx/include/typeindex
+++ b/contrib/llvm-project/libcxx/include/typeindex
@@ -45,8 +45,10 @@ struct hash<type_index>
*/
#include <__config>
-#include <typeinfo>
+#include <__functional/unary_function.h>
#include <__functional_base>
+#include <compare>
+#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -99,4 +101,4 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index>
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_TYPEINDEX
+#endif // _LIBCPP_TYPEINDEX
diff --git a/contrib/llvm-project/libcxx/include/typeinfo b/contrib/llvm-project/libcxx/include/typeinfo
index 048e57614aff..6026038ba5f9 100644
--- a/contrib/llvm-project/libcxx/include/typeinfo
+++ b/contrib/llvm-project/libcxx/include/typeinfo
@@ -56,12 +56,13 @@ public:
*/
-#include <__config>
#include <__availability>
-#include <exception>
+#include <__config>
#include <cstddef>
#include <cstdint>
+#include <exception>
#include <type_traits>
+
#ifdef _LIBCPP_NO_EXCEPTIONS
#include <cstdlib>
#endif
@@ -125,7 +126,7 @@ public:
// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 1)
// ------------------------------------------------------------------------- //
// This implementation of type_info assumes a unique copy of the RTTI for a
-// given type inside a program. This is a valid assumption when abiding to
+// given type inside a program. This is a valid assumption when abiding to the
// Itanium ABI (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-components).
// Under this assumption, we can always compare the addresses of the type names
// to implement equality-comparison of type_infos instead of having to perform
@@ -144,22 +145,29 @@ public:
// NonUniqueARMRTTIBit
// (_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION = 3)
// -------------------------------------------------------------------------- //
+// This implementation is specific to ARM64 on Apple platforms.
+//
// This implementation of type_info does not assume always a unique copy of
-// the RTTI for a given type inside a program. It packs the pointer to the
-// type name into a uintptr_t and reserves the high bit of that pointer (which
-// is assumed to be free for use under the ABI in use) to represent whether
-// that specific copy of the RTTI can be assumed unique inside the program.
-// To implement equality-comparison of type_infos, we check whether BOTH
-// type_infos are guaranteed unique, and if so, we simply compare the addresses
-// of their type names instead of doing a deep string comparison, which is
-// faster. If at least one of the type_infos can't guarantee uniqueness, we
-// have no choice but to fall back to a deep string comparison.
+// the RTTI for a given type inside a program. When constructing the type_info,
+// the compiler packs the pointer to the type name into a uintptr_t and reserves
+// the high bit of that pointer, which is assumed to be free for use under that
+// ABI. If that high bit is set, that specific copy of the RTTI can't be assumed
+// to be unique within the program. If the high bit is unset, then the RTTI can
+// be assumed to be unique within the program.
//
-// This implementation is specific to ARM64 on Apple platforms.
+// When comparing type_infos, if both RTTIs can be assumed to be unique, it
+// suffices to compare their addresses. If both the RTTIs can't be assumed to
+// be unique, we must perform a deep string comparison of the type names.
+// However, if one of the RTTIs is guaranteed unique and the other one isn't,
+// then both RTTIs are necessarily not to be considered equal.
//
-// Note that the compiler is the one setting (or unsetting) the high bit of
-// the pointer when it constructs the type_info, depending on whether it can
-// guarantee uniqueness for that specific type_info.
+// The intent of this design is to remove the need for weak symbols. Specifically,
+// if a type would normally have a default-visibility RTTI emitted as a weak
+// symbol, it is given hidden visibility instead and the non-unique bit is set.
+// Otherwise, types declared with hidden visibility are always considered to have
+// a unique RTTI: the RTTI is emitted with linkonce_odr linkage and is assumed
+// to be deduplicated by the linker within the linked image. Across linked image
+// boundaries, such types are thus considered different types.
// This value can be overriden in the __config_site. When it's not overriden,
// we pick a default implementation based on the platform here.
@@ -241,20 +249,22 @@ struct __type_info_implementations {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
static size_t __hash(__type_name_t __v) _NOEXCEPT {
if (__is_type_name_unique(__v))
- return reinterpret_cast<size_t>(__v);
+ return __v;
return __non_unique_impl::__hash(__type_name_to_string(__v));
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
static bool __eq(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
if (__lhs == __rhs)
return true;
- if (__is_type_name_unique(__lhs, __rhs))
+ if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
+ // Either both are unique and have a different address, or one of them
+ // is unique and the other one isn't. In both cases they are unequal.
return false;
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) == 0;
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE
static bool __lt(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- if (__is_type_name_unique(__lhs, __rhs))
+ if (__is_type_name_unique(__lhs) || __is_type_name_unique(__rhs))
return __lhs < __rhs;
return __builtin_strcmp(__type_name_to_string(__lhs), __type_name_to_string(__rhs)) < 0;
}
@@ -269,10 +279,6 @@ struct __type_info_implementations {
static bool __is_type_name_unique(__type_name_t __lhs) _NOEXCEPT {
return !(__lhs & __non_unique_rtti_bit::value);
}
- _LIBCPP_INLINE_VISIBILITY
- static bool __is_type_name_unique(__type_name_t __lhs, __type_name_t __rhs) _NOEXCEPT {
- return !((__lhs & __rhs) & __non_unique_rtti_bit::value);
- }
};
typedef
@@ -371,4 +377,4 @@ void __throw_bad_cast()
}
_LIBCPP_END_NAMESPACE_STD
-#endif // __LIBCPP_TYPEINFO
+#endif // __LIBCPP_TYPEINFO
diff --git a/contrib/llvm-project/libcxx/include/unordered_map b/contrib/llvm-project/libcxx/include/unordered_map
index d595302e633b..ea0382de7d40 100644
--- a/contrib/llvm-project/libcxx/include/unordered_map
+++ b/contrib/llvm-project/libcxx/include/unordered_map
@@ -432,15 +432,18 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
*/
#include <__config>
+#include <__debug>
+#include <__functional/is_transparent.h>
#include <__hash_table>
#include <__node_handle>
+#include <__utility/forward.h>
+#include <compare>
#include <functional>
+#include <iterator> // __libcpp_erase_if_container
#include <stdexcept>
#include <tuple>
#include <version>
-#include <__debug>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -684,7 +687,7 @@ public:
{
const_cast<bool&>(__x.__value_constructed) = false;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void operator()(pointer __p) _NOEXCEPT
@@ -700,7 +703,7 @@ public:
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp>
-struct __hash_value_type
+struct _LIBCPP_STANDALONE_DEBUG __hash_value_type
{
typedef _Key key_type;
typedef _Tp mapped_type;
@@ -920,9 +923,9 @@ public:
// types
typedef _Key key_type;
typedef _Tp mapped_type;
- typedef typename __identity<_Hash>::type hasher;
- typedef typename __identity<_Pred>::type key_equal;
- typedef typename __identity<_Alloc>::type allocator_type;
+ typedef __identity_t<_Hash> hasher;
+ typedef __identity_t<_Pred> key_equal;
+ typedef __identity_t<_Alloc> allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -1013,7 +1016,7 @@ public:
unordered_map(initializer_list<value_type> __il, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 11
_LIBCPP_INLINE_VISIBILITY
unordered_map(size_type __n, const allocator_type& __a)
@@ -1066,7 +1069,7 @@ public:
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
_LIBCPP_INLINE_VISIBILITY
unordered_map& operator=(initializer_list<value_type> __il);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
@@ -1171,7 +1174,7 @@ public:
return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 14
template <class... _Args>
@@ -1452,7 +1455,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(&__i->__i_, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
@@ -1718,7 +1721,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
@@ -1778,7 +1781,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
return __r.first->second;
}
-#endif // _LIBCPP_CXX03_MODE
+#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
_Tp&
@@ -1817,7 +1820,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c,
_Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -1857,9 +1860,9 @@ public:
// types
typedef _Key key_type;
typedef _Tp mapped_type;
- typedef typename __identity<_Hash>::type hasher;
- typedef typename __identity<_Pred>::type key_equal;
- typedef typename __identity<_Alloc>::type allocator_type;
+ typedef __identity_t<_Hash> hasher;
+ typedef __identity_t<_Pred> key_equal;
+ typedef __identity_t<_Alloc> allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
@@ -1948,7 +1951,7 @@ public:
unordered_multimap(initializer_list<value_type> __il, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 11
_LIBCPP_INLINE_VISIBILITY
unordered_multimap(size_type __n, const allocator_type& __a)
@@ -2001,7 +2004,7 @@ public:
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
_LIBCPP_INLINE_VISIBILITY
unordered_multimap& operator=(initializer_list<value_type> __il);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
@@ -2070,7 +2073,7 @@ public:
iterator emplace_hint(const_iterator __p, _Args&&... __args) {
return __table_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
@@ -2255,7 +2258,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(&__i->__i_, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
};
@@ -2518,7 +2521,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
@@ -2550,7 +2553,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type
erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c,
_Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -2588,4 +2591,4 @@ operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_UNORDERED_MAP
+#endif // _LIBCPP_UNORDERED_MAP
diff --git a/contrib/llvm-project/libcxx/include/unordered_set b/contrib/llvm-project/libcxx/include/unordered_set
index 80f460d7edaa..a775a9250268 100644
--- a/contrib/llvm-project/libcxx/include/unordered_set
+++ b/contrib/llvm-project/libcxx/include/unordered_set
@@ -387,13 +387,16 @@ template <class Value, class Hash, class Pred, class Alloc>
*/
#include <__config>
+#include <__debug>
+#include <__functional/is_transparent.h>
#include <__hash_table>
#include <__node_handle>
+#include <__utility/forward.h>
+#include <compare>
#include <functional>
+#include <iterator> // __libcpp_erase_if_container
#include <version>
-#include <__debug>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
@@ -411,9 +414,9 @@ public:
// types
typedef _Value key_type;
typedef key_type value_type;
- typedef typename __identity<_Hash>::type hasher;
- typedef typename __identity<_Pred>::type key_equal;
- typedef typename __identity<_Alloc>::type allocator_type;
+ typedef __identity_t<_Hash> hasher;
+ typedef __identity_t<_Pred> key_equal;
+ typedef __identity_t<_Alloc> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
@@ -512,7 +515,7 @@ public:
const hasher& __hf, const allocator_type& __a)
: unordered_set(__il, __n, __hf, key_equal(), __a) {}
#endif
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~unordered_set() {
static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
@@ -530,7 +533,7 @@ public:
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
_LIBCPP_INLINE_VISIBILITY
unordered_set& operator=(initializer_list<value_type> __il);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
@@ -595,7 +598,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert(const value_type& __x)
{return __table_.__insert_unique(__x);}
@@ -792,7 +795,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
};
@@ -1039,7 +1042,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
@@ -1069,7 +1072,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type
erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c,
_Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -1109,9 +1112,9 @@ public:
// types
typedef _Value key_type;
typedef key_type value_type;
- typedef typename __identity<_Hash>::type hasher;
- typedef typename __identity<_Pred>::type key_equal;
- typedef typename __identity<_Alloc>::type allocator_type;
+ typedef __identity_t<_Hash> hasher;
+ typedef __identity_t<_Pred> key_equal;
+ typedef __identity_t<_Alloc> allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
@@ -1208,7 +1211,7 @@ public:
unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
: unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
#endif
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
~unordered_multiset() {
static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
@@ -1225,7 +1228,7 @@ public:
unordered_multiset& operator=(unordered_multiset&& __u)
_NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
unordered_multiset& operator=(initializer_list<value_type> __il);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
@@ -1269,7 +1272,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
@@ -1458,7 +1461,7 @@ public:
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
{return __table_.__addable(__i, __n);}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
};
@@ -1705,7 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
return *this;
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
@@ -1735,7 +1738,7 @@ inline _LIBCPP_INLINE_VISIBILITY
typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type
erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c,
_Predicate __pred) {
- return __libcpp_erase_if_container(__c, __pred);
+ return _VSTD::__libcpp_erase_if_container(__c, __pred);
}
#endif
@@ -1773,4 +1776,4 @@ operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_UNORDERED_SET
+#endif // _LIBCPP_UNORDERED_SET
diff --git a/contrib/llvm-project/libcxx/include/utility b/contrib/llvm-project/libcxx/include/utility
index 6f27af70646b..83ad035c9f90 100644
--- a/contrib/llvm-project/libcxx/include/utility
+++ b/contrib/llvm-project/libcxx/include/utility
@@ -58,6 +58,14 @@ template <class T> void as_const(const T&&) = delete; // C+
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
+template<class T, class U> constexpr bool cmp_equal(T t, U u) noexcept; // C++20
+template<class T, class U> constexpr bool cmp_not_equal(T t, U u) noexcept; // C++20
+template<class T, class U> constexpr bool cmp_less(T t, U u) noexcept; // C++20
+template<class T, class U> constexpr bool cmp_greater(T t, U u) noexcept; // C++20
+template<class T, class U> constexpr bool cmp_less_equal(T t, U u) noexcept; // C++20
+template<class T, class U> constexpr bool cmp_greater_equal(T t, U u) noexcept; // C++20
+template<class R, class T> constexpr bool in_range(T t) noexcept; // C++20
+
template <class T1, class T2>
struct pair
{
@@ -76,15 +84,15 @@ struct pair
template <class U, class V> explicit(see-below) pair(pair<U, V>&& p); // constexpr in C++14
template <class... Args1, class... Args2>
pair(piecewise_construct_t, tuple<Args1...> first_args,
- tuple<Args2...> second_args);
+ tuple<Args2...> second_args); // constexpr in C++20
- template <class U, class V> pair& operator=(const pair<U, V>& p);
+ template <class U, class V> pair& operator=(const pair<U, V>& p); // constexpr in C++20
pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
- is_nothrow_move_assignable<T2>::value);
- template <class U, class V> pair& operator=(pair<U, V>&& p);
+ is_nothrow_move_assignable<T2>::value); // constexpr in C++20
+ template <class U, class V> pair& operator=(pair<U, V>&& p); // constexpr in C++20
void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
- is_nothrow_swappable_v<T2>);
+ is_nothrow_swappable_v<T2>); // constexpr in C++20
};
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
@@ -94,10 +102,10 @@ template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,
template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
-template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14
+template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14
template <class T1, class T2>
void
-swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
+swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
@@ -191,1439 +199,32 @@ template <size_t I>
template <size_t I>
inline constexpr in_place_index_t<I> in_place_index{};
+// [utility.underlying], to_underlying
+template <class T>
+ constexpr underlying_type_t<T> to_underlying( T value ) noexcept; // C++2b
+
} // std
*/
#include <__config>
+#include <__debug>
#include <__tuple>
-#include <type_traits>
+#include <__utility/as_const.h>
+#include <__utility/cmp.h>
+#include <__utility/declval.h>
+#include <__utility/exchange.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/integer_sequence.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <__utility/piecewise_construct.h>
+#include <__utility/rel_ops.h>
+#include <__utility/swap.h>
+#include <__utility/to_underlying.h>
+#include <compare>
#include <initializer_list>
-#include <cstddef>
-#include <cstring>
-#include <cstdint>
#include <version>
-#include <__debug>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-namespace rel_ops
-{
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator!=(const _Tp& __x, const _Tp& __y)
-{
- return !(__x == __y);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator> (const _Tp& __x, const _Tp& __y)
-{
- return __y < __x;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator<=(const _Tp& __x, const _Tp& __y)
-{
- return !(__y < __x);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-bool
-operator>=(const _Tp& __x, const _Tp& __y)
-{
- return !(__x < __y);
-}
-
-} // rel_ops
-
-// swap_ranges is defined in <type_traits>`
-
-// swap is defined in <type_traits>
-
-// move_if_noexcept
-
-template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-#ifndef _LIBCPP_CXX03_LANG
-typename conditional
-<
- !is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value,
- const _Tp&,
- _Tp&&
->::type
-#else // _LIBCPP_CXX03_LANG
-const _Tp&
-#endif
-move_if_noexcept(_Tp& __x) _NOEXCEPT
-{
- return _VSTD::move(__x);
-}
-
-#if _LIBCPP_STD_VER > 14
-template <class _Tp> constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
-template <class _Tp> void as_const(const _Tp&&) = delete;
-#endif
-
-struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { explicit piecewise_construct_t() = default; };
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
-extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
-#else
-/* _LIBCPP_INLINE_VAR */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
-#endif
-
-#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
-template <class, class>
-struct __non_trivially_copyable_base {
- _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- __non_trivially_copyable_base() _NOEXCEPT {}
- _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
- __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
-};
-#endif
-
-template <class _T1, class _T2>
-struct _LIBCPP_TEMPLATE_VIS pair
-#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
-: private __non_trivially_copyable_base<_T1, _T2>
-#endif
-{
- typedef _T1 first_type;
- typedef _T2 second_type;
-
- _T1 first;
- _T2 second;
-
-#if !defined(_LIBCPP_CXX03_LANG)
- pair(pair const&) = default;
- pair(pair&&) = default;
-#else
- // Use the implicitly declared copy constructor in C++03
-#endif
-
-#ifdef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
- pair() : first(), second() {}
-
- _LIBCPP_INLINE_VISIBILITY
- pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {}
-
- template <class _U1, class _U2>
- _LIBCPP_INLINE_VISIBILITY
- pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
-
- _LIBCPP_INLINE_VISIBILITY
- pair& operator=(pair const& __p) {
- first = __p.first;
- second = __p.second;
- return *this;
- }
-#else
- template <bool _Val>
- using _EnableB _LIBCPP_NODEBUG_TYPE = typename enable_if<_Val, bool>::type;
-
- struct _CheckArgs {
- template <int&...>
- static constexpr bool __enable_explicit_default() {
- return is_default_constructible<_T1>::value
- && is_default_constructible<_T2>::value
- && !__enable_implicit_default<>();
- }
-
- template <int&...>
- static constexpr bool __enable_implicit_default() {
- return __is_implicitly_default_constructible<_T1>::value
- && __is_implicitly_default_constructible<_T2>::value;
- }
-
- template <class _U1, class _U2>
- static constexpr bool __enable_explicit() {
- return is_constructible<first_type, _U1>::value
- && is_constructible<second_type, _U2>::value
- && (!is_convertible<_U1, first_type>::value
- || !is_convertible<_U2, second_type>::value);
- }
-
- template <class _U1, class _U2>
- static constexpr bool __enable_implicit() {
- return is_constructible<first_type, _U1>::value
- && is_constructible<second_type, _U2>::value
- && is_convertible<_U1, first_type>::value
- && is_convertible<_U2, second_type>::value;
- }
- };
-
- template <bool _MaybeEnable>
- using _CheckArgsDep _LIBCPP_NODEBUG_TYPE = typename conditional<
- _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
-
- struct _CheckTupleLikeConstructor {
- template <class _Tuple>
- static constexpr bool __enable_implicit() {
- return __tuple_convertible<_Tuple, pair>::value;
- }
-
- template <class _Tuple>
- static constexpr bool __enable_explicit() {
- return __tuple_constructible<_Tuple, pair>::value
- && !__tuple_convertible<_Tuple, pair>::value;
- }
-
- template <class _Tuple>
- static constexpr bool __enable_assign() {
- return __tuple_assignable<_Tuple, pair>::value;
- }
- };
-
- template <class _Tuple>
- using _CheckTLC _LIBCPP_NODEBUG_TYPE = typename conditional<
- __tuple_like_with_size<_Tuple, 2>::value
- && !is_same<typename decay<_Tuple>::type, pair>::value,
- _CheckTupleLikeConstructor,
- __check_tuple_constructor_fail
- >::type;
-
- template<bool _Dummy = true, _EnableB<
- _CheckArgsDep<_Dummy>::__enable_explicit_default()
- > = false>
- explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
- is_nothrow_default_constructible<second_type>::value)
- : first(), second() {}
-
- template<bool _Dummy = true, _EnableB<
- _CheckArgsDep<_Dummy>::__enable_implicit_default()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
- is_nothrow_default_constructible<second_type>::value)
- : first(), second() {}
-
- template <bool _Dummy = true, _EnableB<
- _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit pair(_T1 const& __t1, _T2 const& __t2)
- _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
- is_nothrow_copy_constructible<second_type>::value)
- : first(__t1), second(__t2) {}
-
- template<bool _Dummy = true, _EnableB<
- _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- pair(_T1 const& __t1, _T2 const& __t2)
- _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
- is_nothrow_copy_constructible<second_type>::value)
- : first(__t1), second(__t2) {}
-
- template<class _U1, class _U2, _EnableB<
- _CheckArgs::template __enable_explicit<_U1, _U2>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit pair(_U1&& __u1, _U2&& __u2)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
- is_nothrow_constructible<second_type, _U2>::value))
- : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
-
- template<class _U1, class _U2, _EnableB<
- _CheckArgs::template __enable_implicit<_U1, _U2>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- pair(_U1&& __u1, _U2&& __u2)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
- is_nothrow_constructible<second_type, _U2>::value))
- : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
-
- template<class _U1, class _U2, _EnableB<
- _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit pair(pair<_U1, _U2> const& __p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
- is_nothrow_constructible<second_type, _U2 const&>::value))
- : first(__p.first), second(__p.second) {}
-
- template<class _U1, class _U2, _EnableB<
- _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- pair(pair<_U1, _U2> const& __p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
- is_nothrow_constructible<second_type, _U2 const&>::value))
- : first(__p.first), second(__p.second) {}
-
- template<class _U1, class _U2, _EnableB<
- _CheckArgs::template __enable_explicit<_U1, _U2>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit pair(pair<_U1, _U2>&&__p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
- is_nothrow_constructible<second_type, _U2&&>::value))
- : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
-
- template<class _U1, class _U2, _EnableB<
- _CheckArgs::template __enable_implicit<_U1, _U2>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- pair(pair<_U1, _U2>&& __p)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
- is_nothrow_constructible<second_type, _U2&&>::value))
- : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
-
- template<class _Tuple, _EnableB<
- _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- explicit pair(_Tuple&& __p)
- : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
- second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
-
- template<class _Tuple, _EnableB<
- _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- pair(_Tuple&& __p)
- : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
- second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
-
- template <class... _Args1, class... _Args2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair(piecewise_construct_t __pc,
- tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
- _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
- is_nothrow_constructible<second_type, _Args2...>::value))
- : pair(__pc, __first_args, __second_args,
- typename __make_tuple_indices<sizeof...(_Args1)>::type(),
- typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair& operator=(typename conditional<
- is_copy_assignable<first_type>::value &&
- is_copy_assignable<second_type>::value,
- pair, __nat>::type const& __p)
- _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
- is_nothrow_copy_assignable<second_type>::value)
- {
- first = __p.first;
- second = __p.second;
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair& operator=(typename conditional<
- is_move_assignable<first_type>::value &&
- is_move_assignable<second_type>::value,
- pair, __nat>::type&& __p)
- _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
- is_nothrow_move_assignable<second_type>::value)
- {
- first = _VSTD::forward<first_type>(__p.first);
- second = _VSTD::forward<second_type>(__p.second);
- return *this;
- }
-
- template <class _Tuple, _EnableB<
- _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
- > = false>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair& operator=(_Tuple&& __p) {
- first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
- second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
- return *this;
- }
-#endif
-
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void
- swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
- __is_nothrow_swappable<second_type>::value)
- {
- using _VSTD::swap;
- swap(first, __p.first);
- swap(second, __p.second);
- }
-private:
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- pair(piecewise_construct_t,
- tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
- __tuple_indices<_I1...>, __tuple_indices<_I2...>);
-#endif
-};
-
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-template<class _T1, class _T2>
-pair(_T1, _T2) -> pair<_T1, _T2>;
-#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-bool
-operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
-{
- return __x.first == __y.first && __x.second == __y.second;
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-bool
-operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
-{
- return !(__x == __y);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-bool
-operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
-{
- return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-bool
-operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
-{
- return __y < __x;
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-bool
-operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
-{
- return !(__x < __y);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-bool
-operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
-{
- return !(__y < __x);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-typename enable_if
-<
- __is_swappable<_T1>::value &&
- __is_swappable<_T2>::value,
- void
->::type
-swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
- _NOEXCEPT_((__is_nothrow_swappable<_T1>::value &&
- __is_nothrow_swappable<_T2>::value))
-{
- __x.swap(__y);
-}
-
-template <class _Tp>
-struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; };
-
-template <class _Tp>
-struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; };
-
-#if _LIBCPP_STD_VER > 17
-template <class _Tp>
-struct unwrap_reference : __unwrap_reference<_Tp> { };
-
-template <class _Tp>
-struct unwrap_ref_decay : unwrap_reference<typename decay<_Tp>::type> { };
-#endif // > C++17
-
-template <class _Tp>
-struct __unwrap_ref_decay
-#if _LIBCPP_STD_VER > 17
- : unwrap_ref_decay<_Tp>
-#else
- : __unwrap_reference<typename decay<_Tp>::type>
-#endif
-{ };
-
-#ifndef _LIBCPP_CXX03_LANG
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
-make_pair(_T1&& __t1, _T2&& __t2)
-{
- return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
- (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
-}
-
-#else // _LIBCPP_CXX03_LANG
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-pair<_T1,_T2>
-make_pair(_T1 __x, _T2 __y)
-{
- return pair<_T1, _T2>(__x, __y);
-}
-
-#endif // _LIBCPP_CXX03_LANG
-
-template <class _T1, class _T2>
- struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
- : public integral_constant<size_t, 2> {};
-
-template <size_t _Ip, class _T1, class _T2>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> >
-{
- static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
-};
-
-template <class _T1, class _T2>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
-{
- typedef _LIBCPP_NODEBUG_TYPE _T1 type;
-};
-
-template <class _T1, class _T2>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> >
-{
- typedef _LIBCPP_NODEBUG_TYPE _T2 type;
-};
-
-template <size_t _Ip> struct __get_pair;
-
-template <>
-struct __get_pair<0>
-{
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- _T1&
- get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
-
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const _T1&
- get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- _T1&&
- get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
-
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const _T1&&
- get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}
-#endif // _LIBCPP_CXX03_LANG
-};
-
-template <>
-struct __get_pair<1>
-{
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- _T2&
- get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
-
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const _T2&
- get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
-
-#ifndef _LIBCPP_CXX03_LANG
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- _T2&&
- get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
-
- template <class _T1, class _T2>
- static
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const _T2&&
- get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);}
-#endif // _LIBCPP_CXX03_LANG
-};
-
-template <size_t _Ip, class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-typename tuple_element<_Ip, pair<_T1, _T2> >::type&
-get(pair<_T1, _T2>& __p) _NOEXCEPT
-{
- return __get_pair<_Ip>::get(__p);
-}
-
-template <size_t _Ip, class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
-get(const pair<_T1, _T2>& __p) _NOEXCEPT
-{
- return __get_pair<_Ip>::get(__p);
-}
-
-#ifndef _LIBCPP_CXX03_LANG
-template <size_t _Ip, class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
-get(pair<_T1, _T2>&& __p) _NOEXCEPT
-{
- return __get_pair<_Ip>::get(_VSTD::move(__p));
-}
-
-template <size_t _Ip, class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
-get(const pair<_T1, _T2>&& __p) _NOEXCEPT
-{
- return __get_pair<_Ip>::get(_VSTD::move(__p));
-}
-#endif // _LIBCPP_CXX03_LANG
-
-#if _LIBCPP_STD_VER > 11
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT
-{
- return __get_pair<0>::get(__p);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT
-{
- return __get_pair<0>::get(__p);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT
-{
- return __get_pair<0>::get(_VSTD::move(__p));
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT
-{
- return __get_pair<0>::get(_VSTD::move(__p));
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT
-{
- return __get_pair<1>::get(__p);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT
-{
- return __get_pair<1>::get(__p);
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT
-{
- return __get_pair<1>::get(_VSTD::move(__p));
-}
-
-template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
-{
- return __get_pair<1>::get(_VSTD::move(__p));
-}
-
-#endif
-
-#if _LIBCPP_STD_VER > 11
-
-template<class _Tp, _Tp... _Ip>
-struct _LIBCPP_TEMPLATE_VIS integer_sequence
-{
- typedef _Tp value_type;
- static_assert( is_integral<_Tp>::value,
- "std::integer_sequence can only be instantiated with an integral type" );
- static
- _LIBCPP_INLINE_VISIBILITY
- constexpr
- size_t
- size() noexcept { return sizeof...(_Ip); }
-};
-
-template<size_t... _Ip>
- using index_sequence = integer_sequence<size_t, _Ip...>;
-
-#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
-
-template <class _Tp, _Tp _Ep>
-using __make_integer_sequence _LIBCPP_NODEBUG_TYPE = __make_integer_seq<integer_sequence, _Tp, _Ep>;
-
-#else
-
-template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked _LIBCPP_NODEBUG_TYPE =
- typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>;
-
-template <class _Tp, _Tp _Ep>
-struct __make_integer_sequence_checked
-{
- static_assert(is_integral<_Tp>::value,
- "std::make_integer_sequence can only be instantiated with an integral type" );
- static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length");
- // Workaround GCC bug by preventing bad installations when 0 <= _Ep
- // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
- typedef _LIBCPP_NODEBUG_TYPE __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
-};
-
-template <class _Tp, _Tp _Ep>
-using __make_integer_sequence _LIBCPP_NODEBUG_TYPE = typename __make_integer_sequence_checked<_Tp, _Ep>::type;
-
-#endif
-
-template<class _Tp, _Tp _Np>
- using make_integer_sequence = __make_integer_sequence<_Tp, _Np>;
-
-template<size_t _Np>
- using make_index_sequence = make_integer_sequence<size_t, _Np>;
-
-template<class... _Tp>
- using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
-
-#endif // _LIBCPP_STD_VER > 11
-
-#if _LIBCPP_STD_VER > 11
-template<class _T1, class _T2 = _T1>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_T1 exchange(_T1& __obj, _T2 && __new_value)
-{
- _T1 __old_value = _VSTD::move(__obj);
- __obj = _VSTD::forward<_T2>(__new_value);
- return __old_value;
-}
-#endif // _LIBCPP_STD_VER > 11
-
-#if _LIBCPP_STD_VER > 14
-
-struct _LIBCPP_TYPE_VIS in_place_t {
- explicit in_place_t() = default;
-};
-_LIBCPP_INLINE_VAR constexpr in_place_t in_place{};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS in_place_type_t {
- explicit in_place_type_t() = default;
-};
-template <class _Tp>
-_LIBCPP_INLINE_VAR constexpr in_place_type_t<_Tp> in_place_type{};
-
-template <size_t _Idx>
-struct _LIBCPP_TYPE_VIS in_place_index_t {
- explicit in_place_index_t() = default;
-};
-template <size_t _Idx>
-_LIBCPP_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{};
-
-template <class _Tp> struct __is_inplace_type_imp : false_type {};
-template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
-
-template <class _Tp>
-using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>;
-
-template <class _Tp> struct __is_inplace_index_imp : false_type {};
-template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
-
-template <class _Tp>
-using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>;
-
-#endif // _LIBCPP_STD_VER > 14
-
-template <class _Arg, class _Result>
-struct _LIBCPP_TEMPLATE_VIS unary_function
-{
- typedef _Arg argument_type;
- typedef _Result result_type;
-};
-
-template <class _Size>
-inline _LIBCPP_INLINE_VISIBILITY
-_Size
-__loadword(const void* __p)
-{
- _Size __r;
- _VSTD::memcpy(&__r, __p, sizeof(__r));
- return __r;
-}
-
-// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
-// is 64 bits. This is because cityhash64 uses 64bit x 64bit
-// multiplication, which can be very slow on 32-bit systems.
-template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__>
-struct __murmur2_or_cityhash;
-
-template <class _Size>
-struct __murmur2_or_cityhash<_Size, 32>
-{
- inline _Size operator()(const void* __key, _Size __len)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK;
-};
-
-// murmur2
-template <class _Size>
-_Size
-__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
-{
- const _Size __m = 0x5bd1e995;
- const _Size __r = 24;
- _Size __h = __len;
- const unsigned char* __data = static_cast<const unsigned char*>(__key);
- for (; __len >= 4; __data += 4, __len -= 4)
- {
- _Size __k = __loadword<_Size>(__data);
- __k *= __m;
- __k ^= __k >> __r;
- __k *= __m;
- __h *= __m;
- __h ^= __k;
- }
- switch (__len)
- {
- case 3:
- __h ^= __data[2] << 16;
- _LIBCPP_FALLTHROUGH();
- case 2:
- __h ^= __data[1] << 8;
- _LIBCPP_FALLTHROUGH();
- case 1:
- __h ^= __data[0];
- __h *= __m;
- }
- __h ^= __h >> 13;
- __h *= __m;
- __h ^= __h >> 15;
- return __h;
-}
-
-template <class _Size>
-struct __murmur2_or_cityhash<_Size, 64>
-{
- inline _Size operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK;
-
- private:
- // Some primes between 2^63 and 2^64.
- static const _Size __k0 = 0xc3a5c85c97cb3127ULL;
- static const _Size __k1 = 0xb492b66fbe98f273ULL;
- static const _Size __k2 = 0x9ae16a3b2f90404fULL;
- static const _Size __k3 = 0xc949d7c7509e6557ULL;
-
- static _Size __rotate(_Size __val, int __shift) {
- return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
- }
-
- static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
- return (__val >> __shift) | (__val << (64 - __shift));
- }
-
- static _Size __shift_mix(_Size __val) {
- return __val ^ (__val >> 47);
- }
-
- static _Size __hash_len_16(_Size __u, _Size __v)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
- {
- const _Size __mul = 0x9ddfea08eb382d69ULL;
- _Size __a = (__u ^ __v) * __mul;
- __a ^= (__a >> 47);
- _Size __b = (__v ^ __a) * __mul;
- __b ^= (__b >> 47);
- __b *= __mul;
- return __b;
- }
-
- static _Size __hash_len_0_to_16(const char* __s, _Size __len)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
- {
- if (__len > 8) {
- const _Size __a = __loadword<_Size>(__s);
- const _Size __b = __loadword<_Size>(__s + __len - 8);
- return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
- }
- if (__len >= 4) {
- const uint32_t __a = __loadword<uint32_t>(__s);
- const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
- return __hash_len_16(__len + (__a << 3), __b);
- }
- if (__len > 0) {
- const unsigned char __a = __s[0];
- const unsigned char __b = __s[__len >> 1];
- const unsigned char __c = __s[__len - 1];
- const uint32_t __y = static_cast<uint32_t>(__a) +
- (static_cast<uint32_t>(__b) << 8);
- const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2);
- return __shift_mix(__y * __k2 ^ __z * __k3) * __k2;
- }
- return __k2;
- }
-
- static _Size __hash_len_17_to_32(const char *__s, _Size __len)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
- {
- const _Size __a = __loadword<_Size>(__s) * __k1;
- const _Size __b = __loadword<_Size>(__s + 8);
- const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
- const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
- return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
- __a + __rotate(__b ^ __k3, 20) - __c + __len);
- }
-
- // Return a 16-byte hash for 48 bytes. Quick and dirty.
- // Callers do best to use "random-looking" values for a and b.
- static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
- _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
- {
- __a += __w;
- __b = __rotate(__b + __a + __z, 21);
- const _Size __c = __a;
- __a += __x;
- __a += __y;
- __b += __rotate(__a, 44);
- return pair<_Size, _Size>(__a + __z, __b + __c);
- }
-
- // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
- static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
- const char* __s, _Size __a, _Size __b)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
- {
- return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
- __loadword<_Size>(__s + 8),
- __loadword<_Size>(__s + 16),
- __loadword<_Size>(__s + 24),
- __a,
- __b);
- }
-
- // Return an 8-byte hash for 33 to 64 bytes.
- static _Size __hash_len_33_to_64(const char *__s, size_t __len)
- _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
- {
- _Size __z = __loadword<_Size>(__s + 24);
- _Size __a = __loadword<_Size>(__s) +
- (__len + __loadword<_Size>(__s + __len - 16)) * __k0;
- _Size __b = __rotate(__a + __z, 52);
- _Size __c = __rotate(__a, 37);
- __a += __loadword<_Size>(__s + 8);
- __c += __rotate(__a, 7);
- __a += __loadword<_Size>(__s + 16);
- _Size __vf = __a + __z;
- _Size __vs = __b + __rotate(__a, 31) + __c;
- __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
- __z += __loadword<_Size>(__s + __len - 8);
- __b = __rotate(__a + __z, 52);
- __c = __rotate(__a, 37);
- __a += __loadword<_Size>(__s + __len - 24);
- __c += __rotate(__a, 7);
- __a += __loadword<_Size>(__s + __len - 16);
- _Size __wf = __a + __z;
- _Size __ws = __b + __rotate(__a, 31) + __c;
- _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
- return __shift_mix(__r * __k0 + __vs) * __k2;
- }
-};
-
-// cityhash64
-template <class _Size>
-_Size
-__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
-{
- const char* __s = static_cast<const char*>(__key);
- if (__len <= 32) {
- if (__len <= 16) {
- return __hash_len_0_to_16(__s, __len);
- } else {
- return __hash_len_17_to_32(__s, __len);
- }
- } else if (__len <= 64) {
- return __hash_len_33_to_64(__s, __len);
- }
-
- // For strings over 64 bytes we hash the end first, and then as we
- // loop we keep 56 bytes of state: v, w, x, y, and z.
- _Size __x = __loadword<_Size>(__s + __len - 40);
- _Size __y = __loadword<_Size>(__s + __len - 16) +
- __loadword<_Size>(__s + __len - 56);
- _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
- __loadword<_Size>(__s + __len - 24));
- pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
- pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
- __x = __x * __k1 + __loadword<_Size>(__s);
-
- // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
- __len = (__len - 1) & ~static_cast<_Size>(63);
- do {
- __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
- __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
- __x ^= __w.second;
- __y += __v.first + __loadword<_Size>(__s + 40);
- __z = __rotate(__z + __w.first, 33) * __k1;
- __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
- __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
- __y + __loadword<_Size>(__s + 16));
- _VSTD::swap(__z, __x);
- __s += 64;
- __len -= 64;
- } while (__len != 0);
- return __hash_len_16(
- __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z,
- __hash_len_16(__v.second, __w.second) + __x);
-}
-
-template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
-struct __scalar_hash;
-
-template <class _Tp>
-struct __scalar_hash<_Tp, 0>
- : public unary_function<_Tp, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp __v) const _NOEXCEPT
- {
- union
- {
- _Tp __t;
- size_t __a;
- } __u;
- __u.__a = 0;
- __u.__t = __v;
- return __u.__a;
- }
-};
-
-template <class _Tp>
-struct __scalar_hash<_Tp, 1>
- : public unary_function<_Tp, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp __v) const _NOEXCEPT
- {
- union
- {
- _Tp __t;
- size_t __a;
- } __u;
- __u.__t = __v;
- return __u.__a;
- }
-};
-
-template <class _Tp>
-struct __scalar_hash<_Tp, 2>
- : public unary_function<_Tp, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp __v) const _NOEXCEPT
- {
- union
- {
- _Tp __t;
- struct
- {
- size_t __a;
- size_t __b;
- } __s;
- } __u;
- __u.__t = __v;
- return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
- }
-};
-
-template <class _Tp>
-struct __scalar_hash<_Tp, 3>
- : public unary_function<_Tp, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp __v) const _NOEXCEPT
- {
- union
- {
- _Tp __t;
- struct
- {
- size_t __a;
- size_t __b;
- size_t __c;
- } __s;
- } __u;
- __u.__t = __v;
- return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
- }
-};
-
-template <class _Tp>
-struct __scalar_hash<_Tp, 4>
- : public unary_function<_Tp, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp __v) const _NOEXCEPT
- {
- union
- {
- _Tp __t;
- struct
- {
- size_t __a;
- size_t __b;
- size_t __c;
- size_t __d;
- } __s;
- } __u;
- __u.__t = __v;
- return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
- }
-};
-
-struct _PairT {
- size_t first;
- size_t second;
-};
-
-_LIBCPP_INLINE_VISIBILITY
-inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
- typedef __scalar_hash<_PairT> _HashT;
- const _PairT __p = {__lhs, __rhs};
- return _HashT()(__p);
-}
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS hash<_Tp*>
- : public unary_function<_Tp*, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp* __v) const _NOEXCEPT
- {
- union
- {
- _Tp* __t;
- size_t __a;
- } __u;
- __u.__t = __v;
- return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
- }
-};
-
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<bool>
- : public unary_function<bool, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<char>
- : public unary_function<char, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<signed char>
- : public unary_function<signed char, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
- : public unary_function<unsigned char, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-#ifndef _LIBCPP_NO_HAS_CHAR8_T
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
- : public unary_function<char8_t, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-#endif // !_LIBCPP_NO_HAS_CHAR8_T
-
-#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
- : public unary_function<char16_t, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
- : public unary_function<char32_t, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
- : public unary_function<wchar_t, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<short>
- : public unary_function<short, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
- : public unary_function<unsigned short, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<int>
- : public unary_function<int, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
- : public unary_function<unsigned int, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<long>
- : public unary_function<long, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
- : public unary_function<unsigned long, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<long long>
- : public __scalar_hash<long long>
-{
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long>
- : public __scalar_hash<unsigned long long>
-{
-};
-
-#ifndef _LIBCPP_HAS_NO_INT128
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<__int128_t>
- : public __scalar_hash<__int128_t>
-{
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t>
- : public __scalar_hash<__uint128_t>
-{
-};
-
-#endif
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<float>
- : public __scalar_hash<float>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(float __v) const _NOEXCEPT
- {
- // -0.0 and 0.0 should return same hash
- if (__v == 0.0f)
- return 0;
- return __scalar_hash<float>::operator()(__v);
- }
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<double>
- : public __scalar_hash<double>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(double __v) const _NOEXCEPT
- {
- // -0.0 and 0.0 should return same hash
- if (__v == 0.0)
- return 0;
- return __scalar_hash<double>::operator()(__v);
- }
-};
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<long double>
- : public __scalar_hash<long double>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(long double __v) const _NOEXCEPT
- {
- // -0.0 and 0.0 should return same hash
- if (__v == 0.0L)
- return 0;
-#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__))
- // Zero out padding bits
- union
- {
- long double __t;
- struct
- {
- size_t __a;
- size_t __b;
- size_t __c;
- size_t __d;
- } __s;
- } __u;
- __u.__s.__a = 0;
- __u.__s.__b = 0;
- __u.__s.__c = 0;
- __u.__s.__d = 0;
- __u.__t = __v;
- return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
-#elif defined(__x86_64__)
- // Zero out padding bits
- union
- {
- long double __t;
- struct
- {
- size_t __a;
- size_t __b;
- } __s;
- } __u;
- __u.__s.__a = 0;
- __u.__s.__b = 0;
- __u.__t = __v;
- return __u.__s.__a ^ __u.__s.__b;
-#else
- return __scalar_hash<long double>::operator()(__v);
-#endif
- }
-};
-
-#if _LIBCPP_STD_VER > 11
-
-template <class _Tp, bool = is_enum<_Tp>::value>
-struct _LIBCPP_TEMPLATE_VIS __enum_hash
- : public unary_function<_Tp, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(_Tp __v) const _NOEXCEPT
- {
- typedef typename underlying_type<_Tp>::type type;
- return hash<type>{}(static_cast<type>(__v));
- }
-};
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
- __enum_hash() = delete;
- __enum_hash(__enum_hash const&) = delete;
- __enum_hash& operator=(__enum_hash const&) = delete;
-};
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
-{
-};
-#endif
-
-#if _LIBCPP_STD_VER > 14
-
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
- : public unary_function<nullptr_t, size_t>
-{
- _LIBCPP_INLINE_VISIBILITY
- size_t operator()(nullptr_t) const _NOEXCEPT {
- return 662607004ull;
- }
-};
-#endif
-
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Key, class _Hash>
-using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
- is_copy_constructible<_Hash>::value &&
- is_move_constructible<_Hash>::value &&
- __invokable_r<size_t, _Hash, _Key const&>::value
->;
-
-template <class _Key, class _Hash = hash<_Key> >
-using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
- __check_hash_requirements<_Key, _Hash>::value &&
- is_default_constructible<_Hash>::value
->;
-
-#if _LIBCPP_STD_VER > 14
-template <class _Type, class>
-using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type;
-
-template <class _Type, class ..._Keys>
-using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type,
- typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type
->;
-#else
-template <class _Type, class ...>
-using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type;
-#endif
-
-#endif // !_LIBCPP_CXX03_LANG
-
-_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_UTILITY
+#endif // _LIBCPP_UTILITY
diff --git a/contrib/llvm-project/libcxx/include/valarray b/contrib/llvm-project/libcxx/include/valarray
index 787d8aca2f8e..6e25514a6a3a 100644
--- a/contrib/llvm-project/libcxx/include/valarray
+++ b/contrib/llvm-project/libcxx/include/valarray
@@ -340,11 +340,11 @@ template <class T> unspecified2 end(const valarray<T>& v);
*/
#include <__config>
-#include <cstddef>
-#include <cmath>
-#include <initializer_list>
#include <algorithm>
+#include <cmath>
+#include <cstddef>
#include <functional>
+#include <initializer_list>
#include <new>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -354,7 +354,6 @@ template <class T> unspecified2 end(const valarray<T>& v);
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
@@ -413,8 +412,8 @@ end(const valarray<_Tp>& __v);
template <class _Op, class _A0>
struct _UnaryOp
{
- typedef typename _Op::result_type result_type;
- typedef typename _A0::value_type value_type;
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
_Op __op_;
_A0 __a0_;
@@ -423,7 +422,7 @@ struct _UnaryOp
_UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __a0_.size();}
@@ -432,8 +431,8 @@ struct _UnaryOp
template <class _Op, class _A0, class _A1>
struct _BinaryOp
{
- typedef typename _Op::result_type result_type;
- typedef typename _A0::value_type value_type;
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
_Op __op_;
_A0 __a0_;
@@ -444,7 +443,7 @@ struct _BinaryOp
: __op_(__op), __a0_(__a0), __a1_(__a1) {}
_LIBCPP_INLINE_VISIBILITY
- value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __a0_.size();}
@@ -455,7 +454,7 @@ class __scalar_expr
{
public:
typedef _Tp value_type;
- typedef const _Tp& result_type;
+ typedef const _Tp& __result_type;
private:
const value_type& __t_;
size_t __s_;
@@ -464,50 +463,56 @@ public:
explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t) const {return __t_;}
+ __result_type operator[](size_t) const {return __t_;}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __s_;}
};
template <class _Tp>
-struct __unary_plus : unary_function<_Tp, _Tp>
+struct __unary_plus
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return +__x;}
};
template <class _Tp>
-struct __bit_not : unary_function<_Tp, _Tp>
+struct __bit_not
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return ~__x;}
};
template <class _Tp>
-struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
+struct __bit_shift_left
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x << __y;}
};
template <class _Tp>
-struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
+struct __bit_shift_right
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x >> __y;}
};
template <class _Tp, class _Fp>
-struct __apply_expr : unary_function<_Tp, _Tp>
+struct __apply_expr
{
private:
_Fp __f_;
public:
+ typedef _Tp __result_type;
+
_LIBCPP_INLINE_VISIBILITY
explicit __apply_expr(_Fp __f) : __f_(__f) {}
@@ -517,128 +522,144 @@ public:
};
template <class _Tp>
-struct __abs_expr : unary_function<_Tp, _Tp>
+struct __abs_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return abs(__x);}
};
template <class _Tp>
-struct __acos_expr : unary_function<_Tp, _Tp>
+struct __acos_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return acos(__x);}
};
template <class _Tp>
-struct __asin_expr : unary_function<_Tp, _Tp>
+struct __asin_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return asin(__x);}
};
template <class _Tp>
-struct __atan_expr : unary_function<_Tp, _Tp>
+struct __atan_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return atan(__x);}
};
template <class _Tp>
-struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
+struct __atan2_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return atan2(__x, __y);}
};
template <class _Tp>
-struct __cos_expr : unary_function<_Tp, _Tp>
+struct __cos_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return cos(__x);}
};
template <class _Tp>
-struct __cosh_expr : unary_function<_Tp, _Tp>
+struct __cosh_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return cosh(__x);}
};
template <class _Tp>
-struct __exp_expr : unary_function<_Tp, _Tp>
+struct __exp_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return exp(__x);}
};
template <class _Tp>
-struct __log_expr : unary_function<_Tp, _Tp>
+struct __log_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return log(__x);}
};
template <class _Tp>
-struct __log10_expr : unary_function<_Tp, _Tp>
+struct __log10_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return log10(__x);}
};
template <class _Tp>
-struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
+struct __pow_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return pow(__x, __y);}
};
template <class _Tp>
-struct __sin_expr : unary_function<_Tp, _Tp>
+struct __sin_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return sin(__x);}
};
template <class _Tp>
-struct __sinh_expr : unary_function<_Tp, _Tp>
+struct __sinh_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return sinh(__x);}
};
template <class _Tp>
-struct __sqrt_expr : unary_function<_Tp, _Tp>
+struct __sqrt_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return sqrt(__x);}
};
template <class _Tp>
-struct __tan_expr : unary_function<_Tp, _Tp>
+struct __tan_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return tan(__x);}
};
template <class _Tp>
-struct __tanh_expr : unary_function<_Tp, _Tp>
+struct __tanh_expr
{
+ typedef _Tp __result_type;
_LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return tanh(__x);}
@@ -650,7 +671,7 @@ class __slice_expr
typedef typename remove_reference<_ValExpr>::type _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
- typedef value_type result_type;
+ typedef value_type __result_type;
private:
_ValExpr __expr_;
@@ -668,7 +689,7 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const
+ __result_type operator[](size_t __i) const
{return __expr_[__start_ + __i * __stride_];}
_LIBCPP_INLINE_VISIBILITY
@@ -690,7 +711,7 @@ class __shift_expr
typedef typename remove_reference<_ValExpr>::type _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
- typedef value_type result_type;
+ typedef value_type __result_type;
private:
_ValExpr __expr_;
@@ -714,7 +735,7 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __j) const
+ __result_type operator[](size_t __j) const
{
ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
@@ -733,7 +754,7 @@ class __cshift_expr
typedef typename remove_reference<_ValExpr>::type _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
- typedef value_type result_type;
+ typedef value_type __result_type;
private:
_ValExpr __expr_;
@@ -764,7 +785,7 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const
+ __result_type operator[](size_t __i) const
{
if (__i < __m_)
return __expr_[__i + __o1_];
@@ -794,7 +815,7 @@ class _LIBCPP_TEMPLATE_VIS valarray
{
public:
typedef _Tp value_type;
- typedef _Tp result_type;
+ typedef _Tp __result_type;
private:
value_type* __begin_;
@@ -814,7 +835,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
valarray(valarray&& __v) _NOEXCEPT;
valarray(initializer_list<value_type> __il);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
valarray(const slice_array<value_type>& __sa);
valarray(const gslice_array<value_type>& __ga);
valarray(const mask_array<value_type>& __ma);
@@ -829,7 +850,7 @@ public:
valarray& operator=(valarray&& __v) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
valarray& operator=(initializer_list<value_type>);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
valarray& operator=(const value_type& __x);
_LIBCPP_INLINE_VISIBILITY
@@ -865,7 +886,7 @@ public:
__val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
_LIBCPP_INLINE_VISIBILITY
gslice_array<value_type> operator[](gslice&& __gs);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
__val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
_LIBCPP_INLINE_VISIBILITY
@@ -875,7 +896,7 @@ public:
__val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
_LIBCPP_INLINE_VISIBILITY
mask_array<value_type> operator[](valarray<bool>&& __vb);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
__val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
_LIBCPP_INLINE_VISIBILITY
@@ -885,7 +906,7 @@ public:
__val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
_LIBCPP_INLINE_VISIBILITY
indirect_array<value_type> operator[](valarray<size_t>&& __vs);
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
// unary operators:
valarray operator+() const;
@@ -1065,8 +1086,8 @@ _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, s
template <class _Op, class _Tp>
struct _UnaryOp<_Op, valarray<_Tp> >
{
- typedef typename _Op::result_type result_type;
- typedef _Tp value_type;
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
_Op __op_;
const valarray<_Tp>& __a0_;
@@ -1075,7 +1096,7 @@ struct _UnaryOp<_Op, valarray<_Tp> >
_UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __a0_.size();}
@@ -1084,8 +1105,8 @@ struct _UnaryOp<_Op, valarray<_Tp> >
template <class _Op, class _Tp, class _A1>
struct _BinaryOp<_Op, valarray<_Tp>, _A1>
{
- typedef typename _Op::result_type result_type;
- typedef _Tp value_type;
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
_Op __op_;
const valarray<_Tp>& __a0_;
@@ -1096,7 +1117,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, _A1>
: __op_(__op), __a0_(__a0), __a1_(__a1) {}
_LIBCPP_INLINE_VISIBILITY
- value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __a0_.size();}
@@ -1105,8 +1126,8 @@ struct _BinaryOp<_Op, valarray<_Tp>, _A1>
template <class _Op, class _A0, class _Tp>
struct _BinaryOp<_Op, _A0, valarray<_Tp> >
{
- typedef typename _Op::result_type result_type;
- typedef _Tp value_type;
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
_Op __op_;
_A0 __a0_;
@@ -1117,7 +1138,7 @@ struct _BinaryOp<_Op, _A0, valarray<_Tp> >
: __op_(__op), __a0_(__a0), __a1_(__a1) {}
_LIBCPP_INLINE_VISIBILITY
- value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __a0_.size();}
@@ -1126,8 +1147,8 @@ struct _BinaryOp<_Op, _A0, valarray<_Tp> >
template <class _Op, class _Tp>
struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
{
- typedef typename _Op::result_type result_type;
- typedef _Tp value_type;
+ typedef typename _Op::__result_type __result_type;
+ typedef typename decay<__result_type>::type value_type;
_Op __op_;
const valarray<_Tp>& __a0_;
@@ -1138,7 +1159,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
: __op_(__op), __a0_(__a0), __a1_(__a1) {}
_LIBCPP_INLINE_VISIBILITY
- value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+ __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __a0_.size();}
@@ -1518,7 +1539,7 @@ public:
__stride_(move(__stride))
{__init(__start);}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
@@ -1668,7 +1689,7 @@ private:
: __vp_(const_cast<value_type*>(__v.__begin_)),
__1d_(move(__gs.__1d_))
{}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class> friend class valarray;
};
@@ -2199,7 +2220,7 @@ class __mask_expr
typedef typename remove_reference<_ValExpr>::type _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
- typedef value_type result_type;
+ typedef value_type __result_type;
private:
_ValExpr __expr_;
@@ -2218,7 +2239,7 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const
+ __result_type operator[](size_t __i) const
{return __expr_[__1d_[__i]];}
_LIBCPP_INLINE_VISIBILITY
@@ -2363,7 +2384,7 @@ private:
__1d_(move(__ia))
{}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class> friend class valarray;
};
@@ -2562,7 +2583,7 @@ class __indirect_expr
typedef typename remove_reference<_ValExpr>::type _RmExpr;
public:
typedef typename _RmExpr::value_type value_type;
- typedef value_type result_type;
+ typedef value_type __result_type;
private:
_ValExpr __expr_;
@@ -2582,11 +2603,11 @@ private:
__1d_(move(__ia))
{}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
public:
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const
+ __result_type operator[](size_t __i) const
{return __expr_[__1d_[__i]];}
_LIBCPP_INLINE_VISIBILITY
@@ -2604,13 +2625,13 @@ class __val_expr
_ValExpr __expr_;
public:
typedef typename _RmExpr::value_type value_type;
- typedef typename _RmExpr::result_type result_type;
+ typedef typename _RmExpr::__result_type __result_type;
_LIBCPP_INLINE_VISIBILITY
explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
_LIBCPP_INLINE_VISIBILITY
- result_type operator[](size_t __i) const
+ __result_type operator[](size_t __i) const
{return __expr_[__i];}
_LIBCPP_INLINE_VISIBILITY
@@ -2673,29 +2694,29 @@ public:
return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
}
- operator valarray<result_type>() const;
+ operator valarray<__result_type>() const;
_LIBCPP_INLINE_VISIBILITY
size_t size() const {return __expr_.size();}
_LIBCPP_INLINE_VISIBILITY
- result_type sum() const
+ __result_type sum() const
{
size_t __n = __expr_.size();
- result_type __r = __n ? __expr_[0] : result_type();
+ __result_type __r = __n ? __expr_[0] : __result_type();
for (size_t __i = 1; __i < __n; ++__i)
__r += __expr_[__i];
return __r;
}
_LIBCPP_INLINE_VISIBILITY
- result_type min() const
+ __result_type min() const
{
size_t __n = size();
- result_type __r = __n ? (*this)[0] : result_type();
+ __result_type __r = __n ? (*this)[0] : __result_type();
for (size_t __i = 1; __i < __n; ++__i)
{
- result_type __x = __expr_[__i];
+ __result_type __x = __expr_[__i];
if (__x < __r)
__r = __x;
}
@@ -2703,13 +2724,13 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
- result_type max() const
+ __result_type max() const
{
size_t __n = size();
- result_type __r = __n ? (*this)[0] : result_type();
+ __result_type __r = __n ? (*this)[0] : __result_type();
for (size_t __i = 1; __i < __n; ++__i)
{
- result_type __x = __expr_[__i];
+ __result_type __x = __expr_[__i];
if (__r < __x)
__r = __x;
}
@@ -2744,16 +2765,16 @@ public:
};
template<class _ValExpr>
-__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
+__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const
{
- valarray<result_type> __r;
+ valarray<__result_type> __r;
size_t __n = __expr_.size();
if (__n)
{
__r.__begin_ =
- __r.__end_ = allocator<result_type>().allocate(__n);
+ __r.__end_ = allocator<__result_type>().allocate(__n);
for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
- ::new ((void*)__r.__end_) result_type(__expr_[__i]);
+ ::new ((void*)__r.__end_) __result_type(__expr_[__i]);
}
return __r;
}
@@ -2772,7 +2793,7 @@ valarray<_Tp>::valarray(size_t __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
::new ((void*)__end_) value_type();
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2782,7 +2803,7 @@ valarray<_Tp>::valarray(size_t __n)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -2806,7 +2827,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2816,7 +2837,7 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -2831,7 +2852,7 @@ valarray<_Tp>::valarray(const valarray& __v)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
::new ((void*)__end_) value_type(*__p);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2841,7 +2862,7 @@ valarray<_Tp>::valarray(const valarray& __v)
__clear(__v.size());
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -2868,7 +2889,7 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
size_t __n_left = __n;
for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
::new ((void*)__end_) value_type(*__p);
@@ -2879,11 +2900,11 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp>
valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
@@ -2897,7 +2918,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
size_t __n_left = __n;
for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
::new ((void*)__end_) value_type(*__p);
@@ -2908,7 +2929,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -2924,7 +2945,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef const size_t* _Ip;
const value_type* __s = __ga.__vp_;
for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
@@ -2937,7 +2958,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -2953,7 +2974,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef const size_t* _Ip;
const value_type* __s = __ma.__vp_;
for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
@@ -2966,7 +2987,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -2982,7 +3003,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef const size_t* _Ip;
const value_type* __s = __ia.__vp_;
for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
@@ -2995,7 +3016,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -3055,7 +3076,7 @@ valarray<_Tp>::operator=(initializer_list<value_type> __il)
return __assign_range(__il.begin(), __il.end());
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp>
inline
@@ -3131,7 +3152,7 @@ valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
resize(__n);
value_type* __t = __begin_;
for (size_t __i = 0; __i != __n; ++__t, ++__i)
- *__t = result_type(__v[__i]);
+ *__t = __result_type(__v[__i]);
return *this;
}
@@ -3185,7 +3206,7 @@ valarray<_Tp>::operator[](gslice&& __gs)
return gslice_array<value_type>(move(__gs), *this);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp>
inline
@@ -3221,7 +3242,7 @@ valarray<_Tp>::operator[](valarray<bool>&& __vb)
return mask_array<value_type>(move(__vb), *this);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp>
inline
@@ -3257,7 +3278,7 @@ valarray<_Tp>::operator[](valarray<size_t>&& __vs)
return indirect_array<value_type>(move(__vs), *this);
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Tp>
valarray<_Tp>
@@ -3731,7 +3752,7 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
::new ((void*)__end_) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -3741,7 +3762,7 @@ valarray<_Tp>::resize(size_t __n, value_type __x)
__clear(__n);
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -4905,4 +4926,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_VALARRAY
+#endif // _LIBCPP_VALARRAY
diff --git a/contrib/llvm-project/libcxx/include/variant b/contrib/llvm-project/libcxx/include/variant
index 770dd335bae2..700e6f3f1151 100644
--- a/contrib/llvm-project/libcxx/include/variant
+++ b/contrib/llvm-project/libcxx/include/variant
@@ -199,18 +199,20 @@ namespace std {
*/
-#include <__config>
#include <__availability>
+#include <__config>
+#include <__functional/hash.h>
#include <__tuple>
-#include <array>
+#include <__utility/forward.h>
+#include <__variant/monostate.h>
+#include <compare>
#include <exception>
-#include <functional>
#include <initializer_list>
+#include <limits>
#include <new>
#include <tuple>
#include <type_traits>
#include <utility>
-#include <limits>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -236,6 +238,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// Remove this once we drop support for GCC 5.
#if _LIBCPP_STD_VER > 14 && !(defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW < 6000)
+// Light N-dimensional array of function pointers. Used in place of std::array to avoid
+// adding a dependency.
+template<class _Tp, size_t _Size>
+struct __farray {
+ static_assert(_Size > 0, "N-dimensional array should never be empty in std::visit");
+ _Tp __buf_[_Size] = {};
+
+ _LIBCPP_INLINE_VISIBILITY constexpr
+ const _Tp &operator[](size_t __n) const noexcept {
+ return __buf_[__n];
+ }
+};
+
_LIBCPP_NORETURN
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
@@ -318,6 +333,33 @@ using __variant_index_t =
template <class _IndexType>
constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);
+template <class... _Types>
+class _LIBCPP_TEMPLATE_VIS variant;
+
+template <class... _Types>
+_LIBCPP_INLINE_VISIBILITY constexpr variant<_Types...>&
+__as_variant(variant<_Types...>& __vs) noexcept {
+ return __vs;
+}
+
+template <class... _Types>
+_LIBCPP_INLINE_VISIBILITY constexpr const variant<_Types...>&
+__as_variant(const variant<_Types...>& __vs) noexcept {
+ return __vs;
+}
+
+template <class... _Types>
+_LIBCPP_INLINE_VISIBILITY constexpr variant<_Types...>&&
+__as_variant(variant<_Types...>&& __vs) noexcept {
+ return _VSTD::move(__vs);
+}
+
+template <class... _Types>
+_LIBCPP_INLINE_VISIBILITY constexpr const variant<_Types...>&&
+__as_variant(const variant<_Types...>&& __vs) noexcept {
+ return _VSTD::move(__vs);
+}
+
namespace __find_detail {
template <class _Tp, class... _Types>
@@ -469,7 +511,7 @@ private:
template <class _Tp, size_t _Np, typename... _Indices>
inline _LIBCPP_INLINE_VISIBILITY
- static constexpr auto&& __at(const array<_Tp, _Np>& __elems,
+ static constexpr auto&& __at(const __farray<_Tp, _Np>& __elems,
size_t __index, _Indices... __indices) {
return __at(__elems[__index], __indices...);
}
@@ -485,7 +527,7 @@ private:
inline _LIBCPP_INLINE_VISIBILITY
static constexpr auto __make_farray(_Fs&&... __fs) {
__std_visit_visitor_return_type_check<__uncvref_t<_Fs>...>();
- using __result = array<common_type_t<__uncvref_t<_Fs>...>, sizeof...(_Fs)>;
+ using __result = __farray<common_type_t<__uncvref_t<_Fs>...>, sizeof...(_Fs)>;
return __result{{_VSTD::forward<_Fs>(__fs)...}};
}
@@ -564,8 +606,9 @@ struct __variant {
inline _LIBCPP_INLINE_VISIBILITY
static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
_Vs&&... __vs) {
- return __base::__visit_alt(_VSTD::forward<_Visitor>(__visitor),
- _VSTD::forward<_Vs>(__vs).__impl...);
+ return __base::__visit_alt(
+ _VSTD::forward<_Visitor>(__visitor),
+ _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl...);
}
template <class _Visitor, class... _Vs>
@@ -586,6 +629,7 @@ struct __variant {
__make_value_visitor(_VSTD::forward<_Visitor>(__visitor)),
_VSTD::forward<_Vs>(__vs)...);
}
+
#if _LIBCPP_STD_VER > 17
template <class _Rp, class _Visitor, class... _Vs>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1152,7 +1196,7 @@ struct __narrowing_check {
template <class _Dest>
static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>;
template <class _Dest, class _Source>
- using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({_VSTD::declval<_Source>()}));
+ using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({declval<_Source>()}));
};
template <class _Dest, class _Source>
@@ -1637,18 +1681,21 @@ constexpr bool operator>=(const variant<_Types...>& __lhs,
template <class... _Vs>
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
-constexpr void __throw_if_valueless(_Vs&&... __vs) {
- const bool __valueless = (... || __vs.valueless_by_exception());
+ _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void
+ __throw_if_valueless(_Vs&&... __vs) {
+ const bool __valueless =
+ (... || _VSTD::__as_variant(__vs).valueless_by_exception());
if (__valueless) {
- __throw_bad_variant_access();
+ __throw_bad_variant_access();
}
}
-template <class _Visitor, class... _Vs>
+template <
+ class _Visitor, class... _Vs,
+ typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
-constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
+ _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr
+ decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
using __variant_detail::__visitation::__variant;
_VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),
@@ -1656,10 +1703,12 @@ constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
}
#if _LIBCPP_STD_VER > 17
-template <class _Rp, class _Visitor, class... _Vs>
+template <
+ class _Rp, class _Visitor, class... _Vs,
+ typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >
inline _LIBCPP_INLINE_VISIBILITY
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
-constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
+ _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp
+ visit(_Visitor&& __visitor, _Vs&&... __vs) {
using __variant_detail::__visitation::__variant;
_VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
return __variant::__visit_value<_Rp>(_VSTD::forward<_Visitor>(__visitor),
@@ -1667,26 +1716,6 @@ constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
}
#endif
-struct _LIBCPP_TEMPLATE_VIS monostate {};
-
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<(monostate, monostate) noexcept { return false; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>(monostate, monostate) noexcept { return false; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator<=(monostate, monostate) noexcept { return true; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator>=(monostate, monostate) noexcept { return true; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(monostate, monostate) noexcept { return true; }
-
-inline _LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(monostate, monostate) noexcept { return false; }
-
template <class... _Types>
inline _LIBCPP_INLINE_VISIBILITY
auto swap(variant<_Types...>& __lhs,
@@ -1719,21 +1748,32 @@ struct _LIBCPP_TEMPLATE_VIS hash<
}
};
-template <>
-struct _LIBCPP_TEMPLATE_VIS hash<monostate> {
- using argument_type = monostate;
- using result_type = size_t;
+// __unchecked_get is the same as std::get, except, it is UB to use it with the wrong
+// type whereas std::get will throw or returning nullptr. This makes it faster than
+// std::get.
+template <size_t _Ip, class _Vp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr auto&& __unchecked_get(_Vp&& __v) noexcept {
+ using __variant_detail::__access::__variant;
+ return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
+}
- inline _LIBCPP_INLINE_VISIBILITY
- result_type operator()(const argument_type&) const _NOEXCEPT {
- return 66740831; // return a fundamentally attractive random value.
- }
-};
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr auto&& __unchecked_get(const variant<_Types...>& __v) noexcept {
+ return __unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
+
+template <class _Tp, class... _Types>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr auto&& __unchecked_get(variant<_Types...>& __v) noexcept {
+ return __unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
+}
-#endif // _LIBCPP_STD_VER > 14
+#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_VARIANT
+#endif // _LIBCPP_VARIANT
diff --git a/contrib/llvm-project/libcxx/include/vector b/contrib/llvm-project/libcxx/include/vector
index 8e2df79f9284..9189ed44a80c 100644
--- a/contrib/llvm-project/libcxx/include/vector
+++ b/contrib/llvm-project/libcxx/include/vector
@@ -144,7 +144,7 @@ public:
public:
reference(const reference&) noexcept;
operator bool() const noexcept;
- reference& operator=(const bool x) noexcept;
+ reference& operator=(bool x) noexcept;
reference& operator=(const reference& x) noexcept;
iterator operator&() const noexcept;
void flip() noexcept;
@@ -272,21 +272,23 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
*/
#include <__config>
-#include <iosfwd> // for forward declaration of vector
#include <__bit_reference>
-#include <type_traits>
+#include <__debug>
+#include <__functional_base>
+#include <__iterator/wrap_iter.h>
+#include <__split_buffer>
+#include <__utility/forward.h>
+#include <algorithm>
#include <climits>
-#include <limits>
+#include <compare>
+#include <cstring>
#include <initializer_list>
+#include <iosfwd> // for forward declaration of vector
+#include <limits>
#include <memory>
#include <stdexcept>
-#include <algorithm>
-#include <cstring>
+#include <type_traits>
#include <version>
-#include <__split_buffer>
-#include <__functional_base>
-
-#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -557,7 +559,7 @@ public:
}
vector(const vector& __x);
- vector(const vector& __x, const allocator_type& __a);
+ vector(const vector& __x, const __identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(const vector& __x);
@@ -577,7 +579,7 @@ public:
#endif
_LIBCPP_INLINE_VISIBILITY
- vector(vector&& __x, const allocator_type& __a);
+ vector(vector&& __x, const __identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __x)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
@@ -586,7 +588,7 @@ public:
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
template <class _InputIterator>
typename enable_if
@@ -673,22 +675,22 @@ public:
_LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
{
- _LIBCPP_ASSERT(!empty(), "front() called for empty vector");
+ _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
_LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
{
- _LIBCPP_ASSERT(!empty(), "front() called for empty vector");
+ _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
return *this->__begin_;
}
_LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
{
- _LIBCPP_ASSERT(!empty(), "back() called for empty vector");
+ _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
_LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
{
- _LIBCPP_ASSERT(!empty(), "back() called for empty vector");
+ _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
return *(this->__end_ - 1);
}
@@ -733,7 +735,7 @@ public:
iterator insert(const_iterator __position, value_type&& __x);
template <class... _Args>
iterator emplace(const_iterator __position, _Args&&... __args);
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
iterator insert(const_iterator __position, size_type __n, const_reference __x);
template <class _InputIterator>
@@ -796,7 +798,7 @@ public:
bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
private:
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
@@ -931,18 +933,18 @@ private:
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
template<class _InputIterator,
- class _Alloc = allocator<typename iterator_traits<_InputIterator>::value_type>,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class _Alloc = allocator<__iter_value_type<_InputIterator>>,
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
vector(_InputIterator, _InputIterator)
- -> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> vector<__iter_value_type<_InputIterator>, _Alloc>;
template<class _InputIterator,
class _Alloc,
- class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ class = _EnableIf<__is_allocator<_Alloc>::value>
>
vector(_InputIterator, _InputIterator, _Alloc)
- -> vector<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
+ -> vector<__iter_value_type<_InputIterator>, _Alloc>;
#endif
template <class _Tp, class _Allocator>
@@ -1027,7 +1029,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
- return _VSTD::max<size_type>(2*__cap, __new_size);
+ return _VSTD::max<size_type>(2 * __cap, __new_size);
}
// Default constructs __n objects starting at __end_
@@ -1261,7 +1263,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
}
template <class _Tp, class _Allocator>
-vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
+vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -1299,7 +1301,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
-vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
+vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a)
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL == 2
@@ -1392,7 +1394,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
#endif
}
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1598,7 +1600,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
__swap_out_circular_buffer(__v);
@@ -1607,7 +1609,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
catch (...)
{
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -1690,14 +1692,14 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
#endif
}
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
inline
void
vector<_Tp, _Allocator>::pop_back()
{
- _LIBCPP_ASSERT(!empty(), "vector::pop_back called for empty vector");
+ _LIBCPP_ASSERT(!empty(), "vector::pop_back called on an empty vector");
this->__destruct_at_end(this->__end_ - 1);
}
@@ -1865,7 +1867,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
return __make_iter(__p);
}
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::iterator
@@ -1941,7 +1943,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__v.__construct_at_end(__first, __last);
difference_type __old_size = __old_last - this->__begin_;
difference_type __old_p = __p - this->__begin_;
@@ -1955,7 +1957,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
erase(__make_iter(__old_last), end());
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
__p = _VSTD::rotate(__p, __old_last, this->__end_);
insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()),
@@ -2114,7 +2116,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
return this->__begin_ <= __p && __p < this->__end_;
}
-#endif // _LIBCPP_DEBUG_LEVEL == 2
+#endif // _LIBCPP_DEBUG_LEVEL == 2
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -2261,7 +2263,7 @@ public:
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
- vector(vector&& __v, const allocator_type& __a);
+ vector(vector&& __v, const __identity_t<allocator_type>& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __v)
_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
@@ -2270,7 +2272,7 @@ public:
vector& operator=(initializer_list<value_type> __il)
{assign(__il.begin(), __il.end()); return *this;}
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
template <class _InputIterator>
typename enable_if
@@ -2573,7 +2575,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
- return _VSTD::max(2*__cap, __align_it(__new_size));
+ return _VSTD::max(2 * __cap, __align_it(__new_size));
}
// Default constructs __n objects starting at __end_
@@ -2708,7 +2710,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __first != __last; ++__first)
push_back(*__first);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2720,7 +2722,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
__invalidate_all_iterators();
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Allocator>
@@ -2735,7 +2737,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
for (; __first != __last; ++__first)
push_back(*__first);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -2747,7 +2749,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
__invalidate_all_iterators();
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
template <class _Allocator>
@@ -2812,7 +2814,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
}
}
-#endif // _LIBCPP_CXX03_LANG
+#endif // _LIBCPP_CXX03_LANG
template <class _Allocator>
vector<bool, _Allocator>::~vector()
@@ -2887,7 +2889,7 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
}
template <class _Allocator>
-vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a)
+vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type>& __a)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, __a)
@@ -2942,7 +2944,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
__c.__cap() = __c.__size_ = 0;
}
-#endif // !_LIBCPP_CXX03_LANG
+#endif // !_LIBCPP_CXX03_LANG
template <class _Allocator>
void
@@ -3028,14 +3030,14 @@ vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
vector(*this, allocator_type(__alloc())).swap(*this);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
}
@@ -3142,7 +3144,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
__v.assign(__first, __last);
difference_type __old_size = static_cast<difference_type>(__old_end - begin());
difference_type __old_p = __p - begin();
@@ -3156,7 +3158,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
erase(__old_end, end());
throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+#endif // _LIBCPP_NO_EXCEPTIONS
}
__p = _VSTD::rotate(__p, __old_end, end());
insert(__p, __v.begin(), __v.end());
@@ -3411,4 +3413,4 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
-#endif // _LIBCPP_VECTOR
+#endif // _LIBCPP_VECTOR
diff --git a/contrib/llvm-project/libcxx/include/version b/contrib/llvm-project/libcxx/include/version
index c021db8bddd7..a0ec730a8ea1 100644
--- a/contrib/llvm-project/libcxx/include/version
+++ b/contrib/llvm-project/libcxx/include/version
@@ -56,7 +56,7 @@ __cpp_lib_constexpr_functional 201907L <functional>
__cpp_lib_constexpr_iterator 201811L <iterator>
__cpp_lib_constexpr_memory 201811L <memory>
__cpp_lib_constexpr_numeric 201911L <numeric>
-__cpp_lib_constexpr_string 201907L <string>
+__cpp_lib_constexpr_string 201811L <string>
__cpp_lib_constexpr_string_view 201811L <string_view>
__cpp_lib_constexpr_tuple 201811L <tuple>
__cpp_lib_constexpr_utility 201811L <utility>
@@ -72,6 +72,7 @@ __cpp_lib_exchange_function 201304L <utility>
__cpp_lib_execution 201902L <execution>
201603L // C++17
__cpp_lib_filesystem 201703L <filesystem>
+__cpp_lib_format 201907L <format>
__cpp_lib_gcd_lcm 201606L <numeric>
__cpp_lib_generic_associative_lookup 201304L <map> <set>
__cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set>
@@ -149,6 +150,7 @@ __cpp_lib_three_way_comparison 201907L <compare>
__cpp_lib_to_address 201711L <memory>
__cpp_lib_to_array 201907L <array>
__cpp_lib_to_chars 201611L <utility>
+__cpp_lib_to_underlying 202102L <utility>
__cpp_lib_transformation_trait_aliases 201304L <type_traits>
__cpp_lib_transparent_operators 201510L <functional> <memory>
201210L // C++14
@@ -158,7 +160,7 @@ __cpp_lib_type_trait_variable_templates 201510L <type_traits>
__cpp_lib_uncaught_exceptions 201411L <exception>
__cpp_lib_unordered_map_try_emplace 201411L <unordered_map>
__cpp_lib_unwrap_ref 201811L <functional>
-__cpp_lib_variant 201606L <variant>
+__cpp_lib_variant 202102L <variant>
__cpp_lib_void_t 201411L <type_traits>
*/
@@ -169,6 +171,8 @@ __cpp_lib_void_t 201411L <type_traits>
#pragma GCC system_header
#endif
+// clang-format off
+
#if _LIBCPP_STD_VER > 11
# define __cpp_lib_chrono_udls 201304L
# define __cpp_lib_complex_udls 201309L
@@ -255,7 +259,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_type_trait_variable_templates 201510L
# define __cpp_lib_uncaught_exceptions 201411L
# define __cpp_lib_unordered_map_try_emplace 201411L
-# define __cpp_lib_variant 201606L
+# define __cpp_lib_variant 202102L
# define __cpp_lib_void_t 201411L
#endif
@@ -279,7 +283,7 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_atomic_shared_ptr 201711L
# endif
# if !defined(_LIBCPP_HAS_NO_THREADS)
-// # define __cpp_lib_atomic_value_initialization 201911L
+# define __cpp_lib_atomic_value_initialization 201911L
# endif
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait)
# define __cpp_lib_atomic_wait 201907L
@@ -287,24 +291,24 @@ __cpp_lib_void_t 201411L <type_traits>
# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier)
# define __cpp_lib_barrier 201907L
# endif
-// # define __cpp_lib_bind_front 201907L
+# define __cpp_lib_bind_front 201907L
// # define __cpp_lib_bit_cast 201806L
// # define __cpp_lib_bitops 201907L
# define __cpp_lib_bounded_array_traits 201902L
-# if !defined(_LIBCPP_NO_HAS_CHAR8_T)
+# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
# define __cpp_lib_char8_t 201811L
# endif
-// # define __cpp_lib_concepts 202002L
-// # define __cpp_lib_constexpr_algorithms 201806L
+# define __cpp_lib_concepts 202002L
+# define __cpp_lib_constexpr_algorithms 201806L
// # define __cpp_lib_constexpr_complex 201711L
# define __cpp_lib_constexpr_dynamic_alloc 201907L
# define __cpp_lib_constexpr_functional 201907L
-// # define __cpp_lib_constexpr_iterator 201811L
-// # define __cpp_lib_constexpr_memory 201811L
+# define __cpp_lib_constexpr_iterator 201811L
+# define __cpp_lib_constexpr_memory 201811L
# define __cpp_lib_constexpr_numeric 201911L
-// # define __cpp_lib_constexpr_string 201907L
-// # define __cpp_lib_constexpr_string_view 201811L
-// # define __cpp_lib_constexpr_tuple 201811L
+# define __cpp_lib_constexpr_string 201811L
+# define __cpp_lib_constexpr_string_view 201811L
+# define __cpp_lib_constexpr_tuple 201811L
# define __cpp_lib_constexpr_utility 201811L
// # define __cpp_lib_constexpr_vector 201907L
// # define __cpp_lib_coroutine 201902L
@@ -315,9 +319,14 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_erase_if 202002L
# undef __cpp_lib_execution
// # define __cpp_lib_execution 201902L
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format)
+// # define __cpp_lib_format 201907L
+# endif
# define __cpp_lib_generic_unordered_lookup 201811L
# define __cpp_lib_int_pow2 202002L
-// # define __cpp_lib_integer_comparison_functions 202002L
+# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
+# define __cpp_lib_integer_comparison_functions 202002L
+# endif
# define __cpp_lib_interpolate 201902L
# if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
# define __cpp_lib_is_constant_evaluated 201811L
@@ -332,7 +341,7 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_latch 201907L
# endif
# define __cpp_lib_list_remove_return_type 201806L
-# if defined(__cpp_concepts) && __cpp_concepts >= 201811L
+# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
# define __cpp_lib_math_constants 201907L
# endif
// # define __cpp_lib_polymorphic_allocator 201902L
@@ -361,6 +370,9 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_stacktrace 202011L
// # define __cpp_lib_stdatomic_h 202011L
# define __cpp_lib_string_contains 202011L
+# define __cpp_lib_to_underlying 202102L
#endif
+// clang-format on
+
#endif // _LIBCPP_VERSIONH
diff --git a/contrib/llvm-project/libcxx/include/wchar.h b/contrib/llvm-project/libcxx/include/wchar.h
index b21a78968e23..c556ae890876 100644
--- a/contrib/llvm-project/libcxx/include/wchar.h
+++ b/contrib/llvm-project/libcxx/include/wchar.h
@@ -177,6 +177,6 @@ size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
size_t nwc, size_t len, mbstate_t *__restrict ps);
} // extern "C++"
-#endif // __cplusplus && _LIBCPP_MSVCRT
+#endif // __cplusplus && _LIBCPP_MSVCRT
-#endif // _LIBCPP_WCHAR_H
+#endif // _LIBCPP_WCHAR_H
diff --git a/contrib/llvm-project/libcxx/include/wctype.h b/contrib/llvm-project/libcxx/include/wctype.h
index 2d4c36d9921d..1b4b1461496c 100644
--- a/contrib/llvm-project/libcxx/include/wctype.h
+++ b/contrib/llvm-project/libcxx/include/wctype.h
@@ -75,6 +75,6 @@ wctrans_t wctrans(const char* property);
#undef towctrans
#undef wctrans
-#endif // __cplusplus
+#endif // __cplusplus
-#endif // _LIBCPP_WCTYPE_H
+#endif // _LIBCPP_WCTYPE_H